Skip to main content

sasvi

Public API for the sasvi SDK: client, auth providers, config, and errors.

Import SVIClient to talk to a SAS Visual Investigator tenant, pair it with a token provider from sasvi.auth, and tune transport behavior through sasvi.config.SVIConfig. Typed failures live in sasvi.errors.

The SVIClient entry point wiring auth, transport, and service layers.

Defines the high-level client that owns authentication, per-service generated clients over the hardened transport, and the handwritten convenience services (documents, alerts, search, workflows, admin, custom requests). Supports use as a sync or async context manager.

ServiceDefinition Objects​

@dataclass(frozen=True)
class ServiceDefinition()

Generated-client import metadata for one Viya service.

Arguments:

  • client_module - Import path for the generated client class.
  • default_path - Default service path appended to the Viya base URL when no explicit service URL override is configured.

client_module​

default_path​

SERVICE_DEFINITIONS​

RAW_API_CLASSES​

SVIClient Objects​

class SVIClient()

High-level entry point for generated and handwritten SDK capabilities.

Use SVIClient when you want one object that owns authentication, generated service clients, and the stable handwritten convenience layer.

Arguments:

  • base_url - Base Viya URL used to derive per-service URLs when config is not provided.
  • auth - Token provider used for SAS authentication. When omitted, auth can be resolved from environment variables.
  • config - Explicit runtime configuration. It is the complete configuration, so passing it together with any other connection or logging keyword argument raises SVIConfigurationError. Use dataclasses.replace(config, ...) to adjust one.
  • service_urls - Optional per-service URL overrides keyed by service name.
  • timeout - Default HTTP timeout in seconds.
  • verify_ssl - TLS verification setting forwarded to HTTPX.
  • follow_redirects - Whether generated clients should follow redirects.
  • default_headers - Default headers applied to all requests.
  • raise_on_unexpected_status - Whether generated clients should raise on unknown status codes.
  • max_retries - Number of retry attempts for retryable requests.
  • retry_backoff_seconds - Base backoff between retries.
  • retry_statuses - HTTP status codes that trigger retries.
  • retry_methods - HTTP methods that are eligible for retries.
  • request_deadline_seconds - Wall-clock budget for one logical request across its retries, or None for no cap. A per-call timeout= cannot extend it.
  • max_response_bytes - Largest response body the SDK reads, 1 GiB by default; None removes the cap. A larger body raises ResponseTooLargeError.
  • limits - httpx2.Limits for the whole client. Every service shares one sync and one async connection pool, and each pool is held to this. See SVIConfig.limits for when it applies per HTTPX client instead.
  • user_agent - User-Agent header value; the default names the SDK, Python and HTTPX versions.
  • sync_httpx_args - Extra keyword arguments forwarded to sync HTTPX clients.
  • async_httpx_args - Extra keyword arguments forwarded to async HTTPX clients.
  • log_level - Optional SDK package log level to apply during client construction.
  • log_http - Whether to emit HTTP request/response summary logs.
  • log_http_level - Log level used for HTTP summary/detail logs.
  • log_http_request_body - Whether to log safe, text request bodies.
  • log_http_response_body - Whether to log safe, text response bodies.
  • log_http_body_limit - Maximum request/response body characters to log.
  • log_http_query - Whether sanitized query strings should be included in logged URLs.
  • log_http_headers - Whether sanitized request/response headers should be logged.
  • log_http_redacted_headers - Additional case-insensitive header names to redact.
  • log_http_redacted_query_params - Additional case-insensitive query names to redact.
  • log_slow_request_seconds - Optional threshold for warning-level slow request logs.
  • echo_connection - Whether to print the connected host once at construction. Defaults to on in an interactive session (REPL or notebook).
  • upload_folder_path - Managed-folder path staged uploads go through.
  • upload_folder_uri - Managed-folder URI that replaces the path lookup when set.

api​

alerts​

admin​

custom​

documents​

runtime_config​

workflows​

verify_connection​

def verify_connection() -> None

Verify connectivity with an explicit synchronous metadata request.

Performs GET /svi-datahub/admin/storedObjects/all to confirm auth and reachability, then marks the client as verified. The call downloads the full representation of every entity type, so it is not a cheap ping on a tenant with a large configuration. In interactive sessions this also prints a one-line confirmation banner.

Raises:

  • AuthConfigurationError - When auth resolution fails before the request is sent.
  • AdminOperationError - When the metadata endpoint returns an error.
  • NetworkError - When the request never completed.
  • TLSError - When TLS negotiation or certificate validation failed.

verify_connection_async​

async def verify_connection_async() -> None

Verify connectivity with an explicit asynchronous metadata request.

See verify_connection for behavior; this variant uses async I/O.

environment_host​

@property
def environment_host() -> str | None

The hostname portion of the configured Viya base URL.

This is primarily useful when auth flows need to explain which Viya host the client will talk to without repeating the full service path.

from_env​

@classmethod
def from_env(cls,
*,
env_file: str | os.PathLike[str] | None = None,
use_login_cache: bool = False,
profile: str | None = None,
settings: ResolvedSettings | None = None,
**overrides: Any) -> SVIClient

Build a client from SASVI_* settings.

With no options this reads only the process environment. A .env file, a named profile and the token that sasvi auth login caches are read only when asked for; the precedence is explicit overrides, then the process environment, then the .env file, then the profile, then the login cache (see sasvi.settings.resolve_settings). Nothing is written to os.environ.

SASVI_VERIFY_SSL takes true or false (or 1/0, yes/no, on/off), or the path of a CA bundle file or certificate directory for a tenant whose certificate a private CA issued. The bundle then replaces the default trust store for this client only.

Arguments:

  • env_file - A .env file whose SASVI_* keys apply below the process environment. The path must exist.
  • use_login_cache - Use the sasvi auth login cache (the profile's, when a profile is named) when no other layer supplies an access token. The token is used only for the origin it was issued for, and so is the TLS setting saved with it.
  • profile - A profile name from profiles.toml (see sasvi.profiles).
  • settings - Settings already resolved with sasvi.settings.resolve_settings. Use instead of the three options above, not with them.
  • **overrides - Explicit constructor overrides. Passed values win over environment variables for the same setting. A token provider built from the credential variables runs its SAS Logon calls with the timeout and verify_ssl the client ends up with (the override, else the variable, else the config); a per-phase httpx2.Timeout leaves the provider's own timeout in place.

Returns:

A configured SVIClient.

Raises:

  • AuthConfigurationError - If SASVI_BASE_URL or compatible auth variables are missing.
  • SVIConfigurationError - If config= is passed together with another connection keyword, or settings= together with env_file, use_login_cache or profile. With config= alone the config wins, and a WARNING names any SASVI_* connection settings it overrode. Also raised when a SASVI_* setting does not parse, for example a SASVI_VERIFY_SSL that is neither a boolean word nor an existing path, when the .env file does not exist, or when the profile is not defined or the profiles file is not valid.

preview_next​

def preview_next() -> AbstractContextManager[PreviewCapture]

Context manager: capture the next handwritten SDK call as a RequestPreview.

Wrap any handwritten SDK call that fires exactly one generated endpoint. The user-facing method runs through its normal body-building / validation, but the HTTP request itself is intercepted and packaged into a RequestPreview instead of firing.

Example::

with svi.preview_next() as p: svi.documents.create_document(entity_type_name="alerts", body={...}) print(p.captured.to_curl())

Multi-call methods (bulk operations, fetch-then-update flows) raise PreviewMultiCallError. For those, use the method's explicit *_preview companion if one exists.

Raises:

  • PreviewMultiCallError - When the block makes a second request.
  • PreviewIncompleteError - When the block captured a read and the method then failed before building the request it was asked about; the read is on the error's captured.

preview​

def preview(callable_: Callable[..., Any], *args: Any,
**kwargs: Any) -> RequestPreview

Functional sugar around preview_next.

Arguments:

  • callable_ - A handwritten SDK method or bound callable to preview. Should be a method that fires a single HTTP request (e.g. svi.alerts.disposition).
  • *args - Positional arguments forwarded to callable_.
  • **kwargs - Keyword arguments forwarded to callable_.

Returns:

The RequestPreview that callable_(*args, **kwargs) would fire, capturing method, URL, headers and body, without firing it.

Raises:

  • PreviewNotCapturedError - When the call returned without making a request.

  • PreviewMultiCallError - When the call made a second request.

  • PreviewIncompleteError - When the call captured a read and then failed before building the request it was asked about.

    Example::

    preview = svi.preview( svi.alerts.disposition, alert_id="alert-1", disposition_id="d-1", ) print(preview.to_curl())

is_closed​

@property
def is_closed() -> bool

Whether the client's synchronous transports have been closed.

A closed client still answers configuration questions; it will not send another request.

forget_upload_folders​

def forget_upload_folders(*, upload_folder_path: str | None = None) -> None

Drop cached upload-folder URIs so the next upload re-resolves them.

The SDK caches the URI it resolved for an upload folder, because every attachment upload needs it and it rarely changes. A folder moved or recreated on the tenant keeps resolving to the old URI until the cache is cleared, so call this after a folder change.

Arguments:

  • upload_folder_path - Drop only this path's entry; omit to clear every cached folder.

close​

def close() -> None

Close synchronous generated clients without hidden async cleanup.

Closing is idempotent: calling this twice, or calling it after close_async, does nothing the second time.

The service clients close first, then custom, then the connection pool they share, then the token provider when the SDK built it from the environment or copied it while binding it. A provider you passed in and that was used unchanged (client.auth is your_provider) stays open for you to close.

close_async​

async def close_async() -> None

Close sync and async generated clients with full awaitable cleanup.

Closing is idempotent, and closes the synchronous transports too, so a client used from both worlds needs one call.

What this sasvi release was built and verified against.

Everything here is known when the package is built: nothing calls a server. The service API majors come from the generator manifest, and the Viya cadences are recorded per release. See website/docs/concepts/compatibility-and-viya-cadence.md for the full matrix across releases.

ServiceApi Objects​

@dataclass(frozen=True, slots=True)
class ServiceApi()

One SAS REST service API this release was generated from.

Attributes:

  • service - Short service key, for example "alerts" or "sand".
  • major - API major version of the OpenAPI spec, for example "6".
  • spec_file - File name of the pinned OpenAPI spec the clients were generated from.

service​

major​

spec_file​

ViyaCadence Objects​

@dataclass(frozen=True, slots=True)
class ViyaCadence()

A SAS Viya cadence this release was built or verified against.

Attributes:

  • track - "Stable" (monthly) or "LTS" (every six months).
  • version - Cadence version in yyyy.mm form, for example "2026.03".
  • live_verified_on - Date the live test suite passed on a tenant running this cadence, or None when the release was built against it but not live-verified.

track​

version​

live_verified_on​

CompatibilityInfo Objects​

@dataclass(frozen=True, slots=True)
class CompatibilityInfo()

Compatibility facts for the installed sasvi release.

A SAS Viya cadence that is not listed was not verified with this release. That does not mean the release fails on it: newer cadences usually keep the same service API majors.

Attributes:

  • sdk_version - The installed sasvi version.
  • running_python - Version of the Python interpreter running this code. It is not a requirement of the release.
  • services - Service API majors the SDK was generated from, sorted by service key.
  • viya_cadences - SAS Viya cadences this release was built or verified against.

sdk_version​

running_python​

services​

viya_cadences​

to_dict​

def to_dict() -> dict[str, object]

Return the facts as a JSON-serializable dict.

Returns:

A dict with plain strings, lists and None; dates are ISO 8601 strings.

compatibility​

def compatibility() -> CompatibilityInfo

Report what this sasvi release was built and verified against.

Makes no network calls, so it works without a tenant. Include the output (or sasvi version --json) in bug reports.

Returns:

The SDK version, the running Python version, the service API majors the SDK was generated from, and the SAS Viya cadences recorded for this release.

generator_version​

def generator_version() -> str

Return the version of the OpenAPI client generator this release was built with.

Makes no network calls. sasvi doctor prints it next to the service API majors.

Returns:

The generator version recorded in the generated tree, for example "0.29.1".

The styling-condition records, below the document runtime and sasvi.admin.

ConfiguredConditionRecord Objects​

@dataclass(frozen=True)
class ConfiguredConditionRecord()

A styling condition configured on an entity type's visual style.

condition_id​

style_id​

evaluation_order​

source​

to_dict​

def to_dict() -> JsonObject

Return the configured condition as a JSON-serializable dict.

DocumentConditionEvaluationResult Objects​

@dataclass(frozen=True)
class DocumentConditionEvaluationResult()

Outcome of evaluating one condition against a specific object.

condition_id​

result​

error_code​

error_message​

requested_object_type​

requested_object_id​

to_dict​

def to_dict() -> JsonObject

Return the evaluation result as a JSON-serializable dict.

The async-job handle, below sasvi.documents and sasvi.admin.

JobHandle Objects​

class JobHandle(RawBackedHandle)

Handle for a submitted async job.

The datahub spec marks the submission endpoint at /admin/asyncJobs as create-only; status polling is documented as living on the SAS Visual Investigator service rather than the data hub itself. This wrapper exposes the fields the server returns on submission but does not yet provide a refresh(). That is a follow-up once the job-monitor service is wrapped.

id​

@property
def id() -> str | None

Server-assigned identifier of the async job.

name​

@property
def name() -> str | None

Human-readable name given to the job.

description​

@property
def description() -> str | None

Free-text description of the job.

status​

@property
def status() -> str | None

Current lifecycle status of the job as reported at submission.

message​

@property
def message() -> str | None

Status or error message returned with the job.

started_by​

@property
def started_by() -> str | None

User who submitted the job.

started_at​

@property
def started_at() -> object | None

Timestamp when the job started.

ended_at​

@property
def ended_at() -> object | None

Timestamp when the job ended, when reported.

Redaction-aware HTTP logging helpers for the SDK transport.

Renders log-safe URLs, headers, and request/response bodies for the transport layer, stripping credentials and other sensitive values (auth headers, tokens, CSRF tokens, secret-shaped body keys) and truncating oversized content before anything reaches a log record.

DEFAULT_REDACTED_HEADERS​

DEFAULT_REDACTED_QUERY_PARAMS​

HTTPLoggingConfig Objects​

@dataclass(frozen=True, slots=True)
class HTTPLoggingConfig()

Internal transport logging configuration.

enabled​

level​

request_body​

response_body​

body_limit​

query​

headers​

redacted_headers​

redacted_query_params​

slow_request_seconds​

normalize_log_level​

def normalize_log_level(level: int | str | None) -> int | None

Normalize a Python logging level value accepted by the SDK.

Arguments:

  • level - A level number, a level name such as "debug" (any case), a numeric string such as "10", or None.

Returns:

The level number, or None when level is None.

Raises:

  • ValueError - When level is an empty string or names no logging level.

log_level_to_dict_value​

def log_level_to_dict_value(level: int | None) -> int | str | None

Return the curated config representation for a normalized log level.

Arguments:

  • level - A level number from normalize_log_level, or None.

Returns:

The standard level name, such as "DEBUG", for a standard level; the number itself for a custom level; None for None.

normalize_redaction_names​

def normalize_redaction_names(values: Sequence[str] | frozenset[str] | None, *,
default: frozenset[str]) -> frozenset[str]

Normalize case-insensitive redaction names.

Arguments:

  • values - Header or query-parameter names to add, in any case. Blank names are dropped. None adds nothing.
  • default - The built-in names. The result always contains all of them, so a caller can widen the redaction set but never narrow it.

Returns:

default united with the lower-cased, stripped values.

package_logger​

def package_logger() -> logging.Logger

Return the root SDK logger.

configure_logging​

def configure_logging(level: int | str | None = None) -> None

Set the SDK package logger level without configuring application handlers.

Arguments:

  • level - Any value normalize_log_level accepts. None leaves the sasvi logger's level unchanged.

Raises:

  • ValueError - When level is an empty string or names no logging level.

safe_url​

def safe_url(
value: object,
*,
include_query: bool = False,
redacted_query_params: frozenset[str] = DEFAULT_REDACTED_QUERY_PARAMS
) -> str

Render a URL for logs without fragments, userinfo, passwords, or unsafe query values.

When include_query is on, the query string is capped at 2048 characters and ends in &truncated=1, so a long search query cannot blow up a log record.

Arguments:

  • value - The URL, as a string, an httpx2.URL or anything whose str() is a URL. A value without a scheme and host is treated as a path and returned without its query and fragment.
  • include_query - Keep the query string, with the values of redacted_query_params replaced by <redacted>. Off by default, which drops the query string.
  • redacted_query_params - Lower-case query-parameter names whose values are hidden when include_query is on.

Returns:

The scheme, host, port and path, plus the redacted query string when include_query is on.

redact_headers​

def redact_headers(
headers: Mapping[str, str],
*,
redacted_headers: frozenset[str] = DEFAULT_REDACTED_HEADERS
) -> dict[str, str]

Return log-safe HTTP headers.

Arguments:

  • headers - The headers to render.
  • redacted_headers - Lower-case header names whose values are replaced by <redacted>. Names in headers match in any case.

Returns:

A copy of headers with the named values replaced.

safe_httpx_args​

def safe_httpx_args(
args: Mapping[str, Any],
*,
redacted_headers: frozenset[str] = DEFAULT_REDACTED_HEADERS
) -> dict[str, object]

Return httpx2 client kwargs with every credential-bearing value redacted.

Headers are redacted by name. Cookies and an auth value are replaced whole, and a proxy URL loses its userinfo.

Arguments:

  • args - Keyword arguments meant for an httpx2.Client or httpx2.AsyncClient.
  • redacted_headers - Lower-case header names whose values are hidden.

Returns:

A shallow copy of args that is safe to print or serialize.

correlation_headers​

def correlation_headers(headers: Mapping[str, str]) -> dict[str, str]

Return selected non-sensitive correlation headers.

Arguments:

  • headers - Request or response headers, matched in any case.

Returns:

The traceparent, x-correlation-id, x-request-id and x-sas-request-id headers that are present, keyed by lower-case name.

render_request_body​

def render_request_body(kwargs: Mapping[str, Any], *,
headers: Mapping[str, str], url: object,
service_name: str | None, limit: int) -> str | None

Render a request body from HTTPX request kwargs when safe and available.

Arguments:

  • kwargs - The keyword arguments for the HTTPX request. The body is read from json, data, content or files, in that order.
  • headers - The request headers; Content-Type decides whether the body is text that can be rendered.
  • url - The request URL. A URL whose path contains /oauth/token has its body withheld.
  • service_name - The calling service's name. "saslogon" has its body withheld.
  • limit - Most characters of body text to keep; the rest is replaced by a truncation marker.

Returns:

The redacted, truncated body text; <redacted auth body> for a token request; a <skipped ...> marker for a binary content type or a multipart or streamed body; None when a request with a text content type carries no body.

Raises:

  • ValueError - When limit is negative and there is text to truncate.

render_response_body​

def render_response_body(response: httpx2.Response,
*,
limit: int,
service_name: str | None = None,
url: object | None = None) -> str | None

Render a response body when safe and available.

A response from the SAS Logon token endpoint carries tokens, so its body is rendered as <redacted auth body> whatever its keys are.

Arguments:

  • response - The HTTPX response whose body to render.
  • limit - Most characters of body text to keep; the rest is replaced by a truncation marker.
  • service_name - The calling service's name. "saslogon" has its body withheld.
  • url - The request URL. A URL whose path contains /oauth/token has its body withheld.

Returns:

The redacted, truncated body text, or a <redacted ...> or <skipped ...> marker when the body is a token response, binary, or cannot be read.

log_http_request​

def log_http_request(logger: logging.Logger, config: HTTPLoggingConfig, *,
service_name: str | None, method: str, url: object,
attempt: int, headers: Mapping[str, str],
kwargs: Mapping[str, Any]) -> None

Log an HTTP request summary and optional safe request details.

Arguments:

  • logger - The logger to write to.
  • config - The client's HTTP logging settings. Nothing is logged unless config.enabled is set.
  • service_name - The calling service's name, recorded on the log line and as sasvi_http_service.
  • method - The HTTP method.
  • url - The request URL, rendered through safe_url.
  • attempt - The 1-based attempt number within a retried request.
  • headers - The request headers, logged redacted when config.headers is set.
  • kwargs - The keyword arguments for the HTTPX request. The body is read from them and logged redacted when config.request_body is set.

log_http_response​

def log_http_response(logger: logging.Logger, config: HTTPLoggingConfig, *,
service_name: str | None, method: str, url: object,
attempt: int, response: httpx2.Response,
duration_ms: float, outcome: str) -> None

Log an HTTP response summary and optional safe response body.

A response slower than config.slow_request_seconds is logged at WARNING or above, and :slow is appended to its outcome.

Arguments:

  • logger - The logger to write to.
  • config - The client's HTTP logging settings. Nothing is logged unless config.enabled is set.
  • service_name - The calling service's name, recorded on the log line and as sasvi_http_service.
  • method - The HTTP method.
  • url - The request URL, rendered through safe_url.
  • attempt - The 1-based attempt number within a retried request.
  • response - The response. Its status, correlation headers, and, when enabled, its redacted headers and body are logged.
  • duration_ms - Time the attempt took, in milliseconds.
  • outcome - How the attempt ended: "retry", "final" or "final:error".

log_http_transport_error​

def log_http_transport_error(logger: logging.Logger, config: HTTPLoggingConfig,
*, service_name: str | None, method: str,
url: object, attempt: int, duration_ms: float,
error: Exception, outcome: str) -> None

Log an HTTP transport error without dumping request payloads.

Arguments:

  • logger - The logger to write to.
  • config - The client's HTTP logging settings. Nothing is logged unless config.enabled is set.
  • service_name - The calling service's name, recorded on the log line and as sasvi_http_service.
  • method - The HTTP method.
  • url - The request URL, rendered through safe_url.
  • attempt - The 1-based attempt number within a retried request.
  • duration_ms - Time the attempt took before it failed, in milliseconds.
  • error - The transport exception. Only its type name is logged.
  • outcome - How the attempt ended: "retry", "final" or "final:error".

Request preview infrastructure for handwritten SDK methods.

Every handwritten method that wraps a generated openapi-python-client endpoint can expose a "preview", a RequestPreview capturing the exact wire request the SDK would fire (method, URL, query string, headers, body) plus a copy-paste curl renderer.

This module is domain-agnostic by design. Adding a preview method to any handwritten method anywhere in the SDK is a 5-line wrapper around build_preview:

from sasvi._preview import build_preview from sasvi._generated.<service>.api.<group> import <op_module>

def my_method_preview(self, **kwargs) -> RequestPreview: return build_preview( op_module=<op_module>, client=self.<service>_api._client, body=self._build_body(**kwargs), **op_query_kwargs, )

The factory works for any generated endpoint because every generated endpoint file exposes a stable _get_kwargs(client=..., body=..., **kw) function. That's the canonical "what would httpx2 send?" contract from the openapi-python-client generator.

OpModule Objects​

class OpModule(Protocol)

Structural contract of a generated openapi-python-client endpoint module.

Every endpoint module produced by the openapi-python-client generator exposes a module-level _get_kwargs(...) function that returns the httpx2 request kwargs (method, url, params, headers, json) the endpoint would fire, plus the module __name__ used for diagnostics. build_preview uses nothing else the module exposes, and nothing domain-specific, so any generated endpoint module satisfies this protocol.

This is the typed seam that lets preview builders accept a generated op-module without importing generated internals directly; obtain the concrete module through the sasvi.api accessor (sasvi.api.op_module) rather than reaching into sasvi._generated.

Attributes:

  • __name__ - Fully-qualified module name, used only for error text.
  • _get_kwargs - Returns the httpx2 request kwargs the endpoint would send for the given call arguments.

RequestPreview Objects​

@dataclass(frozen=True)
class RequestPreview()

The exact wire request a handwritten method would fire.

Captures everything needed to reproduce the call outside the SDK: method, full URL (with query string), headers and body, plus the typed request model for in-Python inspection. Render to a copy-paste curl command via to_curl.

Attributes:

  • method - Uppercase HTTP method (e.g. "POST").
  • base_url - Service base URL the SDK is configured against.
  • path - Endpoint path relative to base_url (e.g. "/searches").
  • query_params - Query-string parameters (already URL-decoded).
  • headers - HTTP headers including SAS-specific media types. Excludes Authorization, which is added at curl-render time.
  • body_dict - JSON body as a plain Python dict, or None when the request has no body or its body is not a JSON object. Use body_json for any JSON body.
  • body_model - The typed generated request model (e.g. SearchRequest) for in-Python inspection. None for bodyless requests.
  • body_json - The JSON body in any shape (object, array, scalar), or None when the body is absent or not JSON.
  • body_content - The raw bytes of a body that is not JSON, or None.

method​

base_url​

path​

query_params​

headers​

body_dict​

body_model​

body_json​

body_content​

url​

@property
def url() -> str

Full URL: base_url + path + URL-encoded query string.

to_curl​

def to_curl(*,
include_auth: bool = False,
token: str | None = None,
multiline: bool = True) -> str

Render the request as a runnable curl command.

Arguments:

  • include_auth - When True, the Authorization header is included in the curl output. When False (default) the output uses Bearer $SASVI_ACCESS_TOKEN as a placeholder so users can export the variable in their shell instead of pasting tokens into logs / chats / tickets.
  • token - An explicit bearer token literal. When supplied, the Authorization header is included with this exact value and include_auth is ignored.
  • multiline - When True (default) the curl command is split across multiple lines for readability; False produces a single-line form.

Returns:

A runnable curl command string. JSON bodies are emitted via a heredoc to avoid shell-quoting pitfalls.

Raises:

  • SVIError - When include_auth is True and no token is given; the preview has no access to the auth provider.

to_httpx​

def to_httpx(*,
async_: bool = False,
token: str | None = None,
env_var: str = "SASVI_ACCESS_TOKEN",
include_imports: bool = True) -> str

Render the request as runnable Python httpx2 code.

Arguments:

  • async_ - When True, emit an async def wrapper using httpx2.AsyncClient. When False (default), emit a sync httpx2.<method>(...) call.
  • token - An explicit bearer token literal. When supplied, the Authorization header substitutes this exact value (Python-escaped). When omitted, the output reads the bearer from os.environ[env_var] so secrets never land in the snippet.
  • env_var - Name of the environment variable that holds the bearer. Defaults to "SASVI_ACCESS_TOKEN", the same placeholder to_curl uses.
  • include_imports - When True (default) emit the import statements and response.raise_for_status() / response.json() boilerplate so the snippet is paste-and-run. False returns only the inline httpx2.<method>(...) call for use inside an existing script.

Returns:

A runnable Python httpx2 snippet string. The renderer writes the JSON body and the header dicts as Python literals, so no shell quoting is involved.

to_dict​

def to_dict() -> JsonObject

Return a JSON-serializable snapshot of the request preview.

build_preview​

def build_preview(*, op_module: OpModule, client: Any,
**op_kwargs: Any) -> RequestPreview

Build a RequestPreview from any generated endpoint module.

Calls op_module._get_kwargs(**op_kwargs), which every openapi-python-client endpoint file exposes, and packages the result into a RequestPreview.

Arguments:

  • op_module - A generated endpoint module satisfying OpModule (e.g. the module returned by sasvi.api.op_module("search")).
  • client - The generated Client / AuthenticatedClient the handwritten method is configured against. Used to resolve the service base URL.
  • **op_kwargs - Forwarded to op_module._get_kwargs(...). Should mirror what the live executor passes (body + query kwargs).

Returns:

A RequestPreview describing the request that would fire.

Raises:

  • SVIError - When op_module exposes no _get_kwargs, or the client's base URL cannot be resolved.

Relationship-type records and their reader, below sasvi.admin and sasvi.documents.

RelationshipTypeFieldRecord Objects​

class RelationshipTypeFieldRecord(RawBackedHandle)

Curated field-definition record for one relationship type.

Arguments:

  • raw - Generated relationship-type field payload.

id​

@property
def id() -> int | None

The field's server-assigned numeric identifier.

name​

@property
def name() -> str | None

The field's programmatic name.

label​

@property
def label() -> str | None

The field's human-readable display label.

description​

@property
def description() -> str | None

The field's descriptive text.

column_name​

@property
def column_name() -> str | None

The physical column name storing this relationship field's values.

data_type​

@property
def data_type() -> str | None

The field's physical storage data type.

logical_data_type​

@property
def logical_data_type() -> str | None

The field's logical data type used for UI and validation.

required​

@property
def required() -> bool

Whether a value is required for this field.

read_only​

@property
def read_only() -> bool

Whether this field is read-only in the UI.

system_reserved​

@property
def system_reserved() -> bool

Whether this field is reserved and managed by the platform.

hidden​

@property
def hidden() -> bool

Whether this field is hidden from the relationship UI.

owner_name​

@property
def owner_name() -> str | None

The name of the relationship type that owns this field.

to_dict​

def to_dict() -> JsonObject

Return a JSON-serializable snapshot of the relationship field definition.

RelationshipTypeRecord Objects​

class RelationshipTypeRecord(RawBackedHandle)

Curated relationship-type definition record.

Arguments:

  • raw - Generated relationship-type payload.

other_entity_type_name​

def other_entity_type_name(entity_type_name: str) -> str | None

Return the opposite endpoint entity type for a participating entity.

Arguments:

  • entity_type_name - Entity type name on one side of the relationship.

Returns:

The opposite endpoint entity type name, or None when the given entity type is not part of the relationship.

other_entity_type_label​

def other_entity_type_label(entity_type_name: str) -> str | None

Return the opposite endpoint entity label for a participating entity.

Arguments:

  • entity_type_name - Entity type name on one side of the relationship.

Returns:

The opposite endpoint entity label, or None when the given entity type is not part of the relationship.

matches_endpoints​

def matches_endpoints(from_type: str, to_type: str) -> bool

Return whether the relationship can connect the given endpoint types.

Direction matters: from_type must be the relationship's from entity. A relationship whose to end is chosen per record by a type field, rather than fixed, matches any to_type.

Arguments:

  • from_type - Entity type name at the from end.
  • to_type - Entity type name at the to end.

Returns:

True when the relationship can link from_type to to_type.

supports_endpoints​

def supports_endpoints(left_type: str, right_type: str) -> bool

Return whether the relationship can connect the given endpoints in either order.

Arguments:

  • left_type - Entity type name at one end.
  • right_type - Entity type name at the other end.

Returns:

True when matches_endpoints holds for (left_type, right_type) or for (right_type, left_type).

id​

@property
def id() -> int | None

The relationship type's server-assigned numeric identifier.

name​

@property
def name() -> str | None

The relationship type's programmatic name.

qualified_name​

@property
def qualified_name() -> str | None

The relationship's fully-qualified name including its endpoint scope.

label​

@property
def label() -> str | None

The forward-direction display label for the relationship.

reverse_name​

@property
def reverse_name() -> str | None

The programmatic name for the reverse direction of the relationship.

reverse_label​

@property
def reverse_label() -> str | None

The display label for the reverse direction of the relationship.

description​

@property
def description() -> str | None

The relationship type's descriptive text.

relationship_type​

@property
def relationship_type() -> str | None

The relationship's kind (e.g. DIRECT_CHILD or a standard relationship).

cardinality​

@property
def cardinality() -> str | None

The relationship's cardinality (e.g. one-to-one or one-to-many).

from_object_name​

@property
def from_object_name() -> str | None

The name of the entity type at the relationship's source endpoint.

from_object_label​

@property
def from_object_label() -> str | None

The label of the entity type at the relationship's source endpoint.

to_object_name​

@property
def to_object_name() -> str | None

The name of the entity type at the relationship's target endpoint.

to_object_label​

@property
def to_object_label() -> str | None

The label of the entity type at the relationship's target endpoint.

managed​

@property
def managed() -> bool

Whether the platform manages this relationship's persistence.

required​

@property
def required() -> bool

Whether this relationship is required for its source entity.

system_reserved​

@property
def system_reserved() -> bool

Whether this relationship type is reserved and managed by the platform.

symmetric​

@property
def symmetric() -> bool

Whether the relationship reads the same in both directions.

join_key_field_name​

@property
def join_key_field_name() -> str | None

The source field whose value joins to the target endpoint.

to_object_type_field_name​

@property
def to_object_type_field_name() -> str | None

The field naming the target entity type for a dynamically-typed endpoint.

fields​

@property
def fields() -> builtins.list[RelationshipTypeFieldRecord]

The field definitions carried on this relationship type.

to_dict​

def to_dict() -> JsonObject

Return a JSON-serializable snapshot of the relationship-type definition.

RelationshipTypesService Objects​

class RelationshipTypesService()

Lookup service for relationship-type definitions.

Arguments:

  • datahub_api - Generated Data Hub API namespace used for relationship lookups.

list​

def list(*, type_: str | None = None) -> builtins.list[RelationshipTypeRecord]

List relationship types, optionally restricted by relationship category.

Arguments:

  • type_ - Optional relationship category/type filter.

Returns:

Curated relationship-type records.

Raises:

  • AdminNotFoundError - When the route answers 404.
  • AdminOperationError - When the server rejects the call, or answers 200 with a body that is not a relationship type or a list of them.

list_async​

async def list_async(*,
type_: str | None = None
) -> builtins.list[RelationshipTypeRecord]

Asynchronously list relationship types, optionally restricted by category.

Arguments:

  • type_ - Optional relationship category/type filter.

Returns:

Curated relationship-type records.

Raises:

  • AdminNotFoundError - When the route answers 404.
  • AdminOperationError - When the server rejects the call, or answers 200 with a body that is not a relationship type or a list of them.

get​

def get(*, qualified_name: str) -> RelationshipTypeRecord | None

Fetch one relationship type by qualified name.

Arguments:

  • qualified_name - Fully qualified relationship-type name.

Returns:

The relationship type record, or None when not found.

Raises:

  • AdminOperationError - When the server rejects the call.

get_async​

async def get_async(*, qualified_name: str) -> RelationshipTypeRecord | None

Asynchronously fetch one relationship type by qualified name.

Arguments:

  • qualified_name - Fully qualified relationship-type name.

Returns:

The relationship type record, or None when not found.

Raises:

  • AdminOperationError - When the server rejects the call.

for_entity_type​

def for_entity_type(
*,
entity_type_name: str,
other_entity_type_name: str | None = None,
type_: str | None = None) -> builtins.list[RelationshipTypeRecord]

Return relationship types connected to one entity type.

Arguments:

  • entity_type_name - Entity type name to match on either side.
  • other_entity_type_name - Optional other endpoint entity type name.
  • type_ - Optional relationship category/type filter.

Returns:

Curated relationship-type records whose from or to side matches the given entity type name, optionally filtered by the opposite side.

Raises:

  • AdminNotFoundError - When the listing route answers 404.
  • AdminOperationError - When the server rejects the listing.

for_entity_type_async​

async def for_entity_type_async(
*,
entity_type_name: str,
other_entity_type_name: str | None = None,
type_: str | None = None) -> builtins.list[RelationshipTypeRecord]

Asynchronously return relationship types connected to one entity type.

Arguments:

  • entity_type_name - Entity type name to match on either side.
  • other_entity_type_name - Optional other endpoint entity type name.
  • type_ - Optional relationship category/type filter.

Returns:

Curated relationship-type records whose from or to side matches the given entity type name, optionally filtered by the opposite side.

Raises:

  • AdminNotFoundError - When the listing route answers 404.
  • AdminOperationError - When the server rejects the listing.

reconstruct​

def reconstruct(*, relationship_type_id: str) -> RelationshipTypeRecord

Reconstruct a relationship type from its stored-object id.

Arguments:

  • relationship_type_id - Stored-object identifier.

Returns:

The reconstructed relationship type record.

Raises:

  • AdminNotFoundError - When no relationship type has that id.
  • AdminOperationError - When the server rejects the call.

reconstruct_async​

async def reconstruct_async(
*, relationship_type_id: str) -> RelationshipTypeRecord

Asynchronously reconstruct a relationship type from its stored-object id.

Arguments:

  • relationship_type_id - Stored-object identifier.

Returns:

The reconstructed relationship type record.

Raises:

  • AdminNotFoundError - When no relationship type has that id.
  • AdminOperationError - When the server rejects the call.

Shared JSON and Python value type aliases used across the SDK surface.

JsonScalar​

A leaf value the SDK returns. Field values arrive deserialized, so dates and decimals count.

JsonValue​

A scalar, or a sequence or mapping of values.

JsonObject​

A JSON object keyed by string. Public as sasvi.types.JsonObject.

PythonScalar​

PythonValue​

PythonObject​