Skip to content

sift_client.client

CLASS DESCRIPTION
SiftClient

SiftClient is a high-level client for interacting with Sift's APIs.

ATTRIBUTE DESCRIPTION
logger

logger module-attribute

logger = logging.getLogger(__name__)

SiftClient

SiftClient(
    api_key: str | None = None,
    grpc_url: str | None = None,
    rest_url: str | None = None,
    connection_config: SiftConnectionConfig | None = None,
    app_url: str | None = None,
    profile: str | None = None,
)

Bases: WithGrpcClient, WithRestClient

SiftClient is a high-level client for interacting with Sift's APIs.

It provides both synchronous and asynchronous interfaces, strong type checking, and a Pythonic API design.

Initialize the SiftClient with specific connection parameters or a connection_config.

For any argument that you leave unset, the client reads the environment and the sift.toml profiles that sift-cli manages. SiftClient() therefore connects to the same endpoints as sift-cli. See :func:sift_client.credentials.resolve_credentials for the full precedence order.

PARAMETER DESCRIPTION
api_key

The Sift API key for authentication.

TYPE: str | None DEFAULT: None

grpc_url

The Sift gRPC API URL.

TYPE: str | None DEFAULT: None

rest_url

The Sift REST API URL.

TYPE: str | None DEFAULT: None

connection_config

A SiftConnectionConfig object to configure the connection behavior of the SiftClient. The client uses it unchanged and resolves no credentials.

TYPE: SiftConnectionConfig | None DEFAULT: None

app_url

The Sift web-app origin (e.g. https://app.siftstack.com). Set this for on-prem or custom deployments whose API host can't be mapped to a frontend automatically; see the app_url property. A value here takes precedence over connection_config.app_url.

TYPE: str | None DEFAULT: None

profile

Name of a sift.toml profile that supplies credentials, as with sift-cli --profile. The client ignores this argument if you also pass connection_config.

TYPE: str | None DEFAULT: None

RAISES DESCRIPTION
SiftCredentialsError

You passed no connection_config, and the client cannot resolve the API key or either URL.

METHOD DESCRIPTION
from_profile

Build a client from a named sift.toml profile.

get_asyncio_loop

Gets the default asyncio loop used by the gRPC client.

ATTRIBUTE DESCRIPTION
ingestion

Instance of the Ingestion API for making synchronous requests.

TYPE: IngestionAPIAsync

cache

Surface for the shared on-disk cache used by every cache-aware resource.

TYPE: CacheNamespace

ping

Instance of the Ping API for making synchronous requests.

TYPE: PingAPI

assets

Instance of the Assets API for making synchronous requests.

TYPE: AssetsAPI

calculated_channels

Instance of the Calculated Channels API for making synchronous requests.

TYPE: CalculatedChannelsAPI

channels

Instance of the Channels API for making synchronous requests.

TYPE: ChannelsAPI

file_attachments

Instance of the File Attachments API for making synchronous requests.

TYPE: FileAttachmentsAPI

jobs

Instance of the Jobs API for making synchronous requests.

TYPE: JobsAPI

rules

Instance of the Rules API for making synchronous requests.

TYPE: RulesAPI

reports

Instance of the Reports API for making synchronous requests.

TYPE: ReportsAPI

runs

Instance of the Runs API for making synchronous requests.

TYPE: RunsAPI

access_control

Access-control APIs for configuring who can access what in Sift.

TYPE: AccessControlAPI

tags

Instance of the Tags API for making synchronous requests.

TYPE: TagsAPI

test_results

Instance of the Test Results API for making synchronous requests.

TYPE: TestResultsAPI

users

Instance of the Users API for making synchronous requests.

TYPE: UsersAPI

data_export

Instance of the Data Export API for making synchronous requests.

TYPE: DataExportAPI

data_import

Instance of the Data Import API for making synchronous requests.

TYPE: DataImportAPI

async_

Accessor for the asynchronous APIs. All asynchronous APIs are available as attributes on this accessor.

TYPE: AsyncAPIs

credential_sources

The layer that supplied each credential. Use it to diagnose a connection.

TYPE: Mapping[str, str] | None

profile

The sift.toml profile that supplied this client's credentials.

TYPE: str | None

grpc_client

The gRPC client used by the SiftClient for making gRPC API calls.

TYPE: GrpcClient

is_loop_running

Whether the background event loop is still accepting synchronous API work.

TYPE: bool

rest_client

The REST client used by the SiftClient for making REST API calls.

TYPE: RestClient

app_url

The Sift web-app origin for this client, or None if it can't be determined.

TYPE: str | None

ingestion instance-attribute

ingestion: IngestionAPIAsync

Instance of the Ingestion API for making synchronous requests.

cache instance-attribute

Surface for the shared on-disk cache used by every cache-aware resource.

ping instance-attribute

ping: PingAPI = PingAPI(self)

Instance of the Ping API for making synchronous requests.

assets instance-attribute

assets: AssetsAPI = AssetsAPI(self)

Instance of the Assets API for making synchronous requests.

calculated_channels instance-attribute

calculated_channels: CalculatedChannelsAPI = (
    CalculatedChannelsAPI(self)
)

Instance of the Calculated Channels API for making synchronous requests.

channels instance-attribute

channels: ChannelsAPI = ChannelsAPI(self)

Instance of the Channels API for making synchronous requests.

file_attachments instance-attribute

file_attachments: FileAttachmentsAPI = FileAttachmentsAPI(
    self
)

Instance of the File Attachments API for making synchronous requests.

jobs instance-attribute

jobs: JobsAPI = JobsAPI(self)

Instance of the Jobs API for making synchronous requests.

rules instance-attribute

rules: RulesAPI = RulesAPI(self)

Instance of the Rules API for making synchronous requests.

reports instance-attribute

reports: ReportsAPI = ReportsAPI(self)

Instance of the Reports API for making synchronous requests.

runs instance-attribute

runs: RunsAPI = RunsAPI(self)

Instance of the Runs API for making synchronous requests.

access_control instance-attribute

access_control: AccessControlAPI = AccessControlAPI(
    resource_attributes=ResourceAttributesAPI(self),
    principal_attributes=PrincipalAttributesAPI(self),
)

Access-control APIs for configuring who can access what in Sift.

tags instance-attribute

tags: TagsAPI = TagsAPI(self)

Instance of the Tags API for making synchronous requests.

test_results instance-attribute

test_results: TestResultsAPI = TestResultsAPI(self)

Instance of the Test Results API for making synchronous requests.

users instance-attribute

users: UsersAPI = UsersAPI(self)

Instance of the Users API for making synchronous requests.

data_export instance-attribute

data_export: DataExportAPI = DataExportAPI(self)

Instance of the Data Export API for making synchronous requests.

data_import instance-attribute

data_import: DataImportAPI = DataImportAPI(self)

Instance of the Data Import API for making synchronous requests.

async_ instance-attribute

async_: AsyncAPIs = AsyncAPIs(
    ping=PingAPIAsync(self),
    assets=AssetsAPIAsync(self),
    calculated_channels=CalculatedChannelsAPIAsync(self),
    channels=ChannelsAPIAsync(self),
    file_attachments=FileAttachmentsAPIAsync(self),
    ingestion=IngestionAPIAsync(self),
    jobs=JobsAPIAsync(self),
    reports=ReportsAPIAsync(self),
    rules=RulesAPIAsync(self),
    runs=RunsAPIAsync(self),
    access_control=AccessControlAPIAsync(
        resource_attributes=ResourceAttributesAPIAsync(
            self
        ),
        principal_attributes=PrincipalAttributesAPIAsync(
            self
        ),
    ),
    tags=TagsAPIAsync(self),
    test_results=TestResultsAPIAsync(self),
    users=UsersAPIAsync(self),
    data_export=DataExportAPIAsync(self),
    data_import=DataImportAPIAsync(self),
)

Accessor for the asynchronous APIs. All asynchronous APIs are available as attributes on this accessor.

credential_sources property

credential_sources: Mapping[str, str] | None

The layer that supplied each credential. Use it to diagnose a connection.

Maps api_key / grpc_url / rest_url / app_url to "arg", "profile:<name>", "env", "default", or "unset". This property is None if you build the client from an explicit connection_config, because that path resolves no credentials.

profile property

profile: str | None

The sift.toml profile that supplied this client's credentials.

grpc_client property

grpc_client: GrpcClient

The gRPC client used by the SiftClient for making gRPC API calls.

is_loop_running property

is_loop_running: bool

Whether the background event loop is still accepting synchronous API work.

rest_client property

rest_client: RestClient

The REST client used by the SiftClient for making REST API calls.

app_url property

app_url: str | None

The Sift web-app origin for this client, or None if it can't be determined.

Uses the explicit override passed at construction when set, otherwise derives the origin from the REST host for known Sift deployments (e.g. https://api.siftstack.com -> https://app.siftstack.com). Returns None for unrecognized hosts with no override.

TODO: Add a WithAppPage mixin on BaseType so resources (TestReport,

a per-type path, instead of callers assembling paths by hand.

from_profile classmethod

from_profile(profile: str, **kwargs) -> SiftClient

Build a client from a named sift.toml profile.

This method calls SiftClient(profile=...). It passes every keyword argument through, and those arguments still outrank the profile's values.

PARAMETER DESCRIPTION
profile

Profile name, as used by sift-cli --profile.

TYPE: str

**kwargs

Any other :class:SiftClient argument.

DEFAULT: {}

RETURNS DESCRIPTION
SiftClient

A client connected to the endpoints that profile names.

get_asyncio_loop

get_asyncio_loop() -> AbstractEventLoop

Gets the default asyncio loop used by the gRPC client.

RETURNS DESCRIPTION
AbstractEventLoop

The default asyncio loop.