Skip to content

sift_client.resources.calculated_channels

CLASS DESCRIPTION
CalculatedChannelsAPIAsync

High-level API for interacting with calculated channels.

CalculatedChannelsAPIAsync

CalculatedChannelsAPIAsync(sift_client: SiftClient)

Bases: ResourceBase

High-level API for interacting with calculated channels.

This class provides a Pythonic, notebook-friendly interface for interacting with the CalculatedChannelsAPI. It handles automatic handling of gRPC services, seamless type conversion, and clear error handling.

All methods in this class use the CalculatedChannel class from the low-level wrapper, which is a user-friendly representation of a calculated channel using standard Python data structures and types.

Initialize the CalculatedChannelsAPI.

PARAMETER DESCRIPTION
sift_client

The Sift client to use.

TYPE: SiftClient

METHOD DESCRIPTION
archive

Archive a Calculated Channel.

create

Create a calculated channel.

find

Find a single calculated channel matching the given query. Takes the same arguments as list but handles checking for multiple matches.

get

Get a Calculated Channel.

list_

List calculated channels with optional filtering.

list_versions

List versions of a calculated channel.

update

Update a Calculated Channel.

archive async

archive(
    *, calculated_channel: str | CalculatedChannel
) -> None

Archive a Calculated Channel.

create async

create(
    *,
    name: str,
    expression: str,
    channel_references: list[ChannelReference],
    description: str = "",
    units: str | None = None,
    client_key: str | None = None,
    asset_ids: list[str] | None = None,
    tag_ids: list[str] | None = None,
    all_assets: bool = False,
    user_notes: str = "",
) -> CalculatedChannel

Create a calculated channel.

PARAMETER DESCRIPTION
name

The name of the calculated channel.

TYPE: str

expression

The expression to calculate the value of the calculated channel.

TYPE: str

channel_references

A list of channel references that are used in the expression.

TYPE: list[ChannelReference]

description

The description of the calculated channel.

TYPE: str DEFAULT: ''

units

The units of the calculated channel.

TYPE: str | None DEFAULT: None

client_key

A user-defined unique identifier for the calculated channel.

TYPE: str | None DEFAULT: None

asset_ids

A list of asset IDs to make the calculation available for.

TYPE: list[str] | None DEFAULT: None

tag_ids

A list of tag IDs to make the calculation available for.

TYPE: list[str] | None DEFAULT: None

all_assets

A flag that, when set to True, associates the calculated channel with all assets.

TYPE: bool DEFAULT: False

user_notes

User notes for the calculated channel.

TYPE: str DEFAULT: ''

RETURNS DESCRIPTION
CalculatedChannel

The created CalculatedChannel.

RAISES DESCRIPTION
ValueError

If asset configuration is invalid.

find async

find(**kwargs) -> CalculatedChannel | None

Find a single calculated channel matching the given query. Takes the same arguments as list but handles checking for multiple matches. Will raise an error if multiple calculated channels are found.

PARAMETER DESCRIPTION
**kwargs

Keyword arguments to pass to list.

DEFAULT: {}

RETURNS DESCRIPTION
CalculatedChannel | None

The CalculatedChannel found or None.

get async

get(
    *,
    calculated_channel_id: str | None = None,
    client_key: str | None = None,
    organization_id: str | None = None,
) -> CalculatedChannel

Get a Calculated Channel.

PARAMETER DESCRIPTION
calculated_channel_id

The ID of the calculated channel.

TYPE: str | None DEFAULT: None

client_key

The client key of the calculated channel.

TYPE: str | None DEFAULT: None

organization_id

The organization ID (required if using client_key and user belongs to multiple organizations).

TYPE: str | None DEFAULT: None

RETURNS DESCRIPTION
CalculatedChannel

The CalculatedChannel.

RAISES DESCRIPTION
ValueError

If neither calculated_channel_id nor client_key is provided.

list_ async

list_(
    *,
    name: str | None = None,
    name_contains: str | None = None,
    name_regex: str | Pattern | None = None,
    created_after: datetime | None = None,
    created_before: datetime | None = None,
    modified_after: datetime | None = None,
    modified_before: datetime | None = None,
    created_by: Any | None = None,
    modified_by: Any | None = None,
    client_key: str | None = None,
    asset_id: str | None = None,
    asset_name: str | None = None,
    tag_id: str | None = None,
    tag_name: str | None = None,
    version: int | None = None,
    include_archived: bool = False,
    filter_query: str | None = None,
    order_by: str | None = None,
    limit: int | None = None,
    organization_id: str | None = None,
) -> list[CalculatedChannel]

List calculated channels with optional filtering.

PARAMETER DESCRIPTION
name

Exact name of the calculated channel.

TYPE: str | None DEFAULT: None

name_contains

Partial name of the calculated channel.

TYPE: str | None DEFAULT: None

name_regex

Regular expression string to filter calculated channels by name.

TYPE: str | Pattern | None DEFAULT: None

created_after

Created after this date.

TYPE: datetime | None DEFAULT: None

created_before

Created before this date.

TYPE: datetime | None DEFAULT: None

modified_after

Modified after this date.

TYPE: datetime | None DEFAULT: None

modified_before

Modified before this date.

TYPE: datetime | None DEFAULT: None

created_by

Calculated channels created by this user.

TYPE: Any | None DEFAULT: None

modified_by

Calculated channels last modified by this user.

TYPE: Any | None DEFAULT: None

client_key

The client key of the calculated channel.

TYPE: str | None DEFAULT: None

asset_id

The asset ID associated with the calculated channel.

TYPE: str | None DEFAULT: None

asset_name

The asset name associated with the calculated channel.

TYPE: str | None DEFAULT: None

tag_id

The tag ID associated with the calculated channel.

TYPE: str | None DEFAULT: None

tag_name

The tag name associated with the calculated channel.

TYPE: str | None DEFAULT: None

version

The version of the calculated channel.

TYPE: int | None DEFAULT: None

include_archived

Include archived calculated channels.

TYPE: bool DEFAULT: False

filter_query

Explicit CEL query to filter calculated channels.

TYPE: str | None DEFAULT: None

order_by

How to order the retrieved calculated channels.

TYPE: str | None DEFAULT: None

limit

How many calculated channels to retrieve. If None, retrieves all matches.

TYPE: int | None DEFAULT: None

organization_id

The organization ID (required if user belongs to multiple organizations).

TYPE: str | None DEFAULT: None

RETURNS DESCRIPTION
list[CalculatedChannel]

A list of CalculatedChannels that matches the filter.

list_versions async

list_versions(
    *,
    calculated_channel_id: str | None = None,
    client_key: str | None = None,
    organization_id: str | None = None,
    name: str | None = None,
    name_contains: str | None = None,
    name_regex: str | Pattern | None = None,
    asset_id: str | None = None,
    asset_name: str | None = None,
    tag_id: str | None = None,
    tag_name: str | None = None,
    version: int | None = None,
    include_archived: bool = False,
    order_by: str | None = None,
    limit: int | None = None,
) -> list[CalculatedChannel]

List versions of a calculated channel.

PARAMETER DESCRIPTION
calculated_channel_id

The ID of the calculated channel.

TYPE: str | None DEFAULT: None

client_key

The client key of the calculated channel.

TYPE: str | None DEFAULT: None

name

The name of the calculated channel.

TYPE: str | None DEFAULT: None

name_contains

The name of the calculated channel.

TYPE: str | None DEFAULT: None

name_regex

The name of the calculated channel.

TYPE: str | Pattern | None DEFAULT: None

asset_id

The asset ID of the calculated channel.

TYPE: str | None DEFAULT: None

asset_name

The asset name of the calculated channel.

TYPE: str | None DEFAULT: None

tag_id

The tag ID of the calculated channel.

TYPE: str | None DEFAULT: None

tag_name

The tag name of the calculated channel.

TYPE: str | None DEFAULT: None

version

The version of the calculated channel.

TYPE: int | None DEFAULT: None

include_archived

Whether to include archived calculated channels.

TYPE: bool DEFAULT: False

organization_id

The organization ID. Required if your user belongs to multiple organizations.

TYPE: str | None DEFAULT: None

order_by

The field to order by.

TYPE: str | None DEFAULT: None

limit

How many versions to retrieve. If None, retrieves all matches.

TYPE: int | None DEFAULT: None

RETURNS DESCRIPTION
list[CalculatedChannel]

A list of CalculatedChannel versions.

RAISES DESCRIPTION
ValueError

If neither calculated_channel_id nor client_key is provided.

update async

update(
    *,
    calculated_channel: str | CalculatedChannel,
    update: CalculatedChannelUpdate | dict,
    user_notes: str | None = None,
) -> CalculatedChannel

Update a Calculated Channel.

PARAMETER DESCRIPTION
calculated_channel

The CalculatedChannel or id of the CalculatedChannel to update.

TYPE: str | CalculatedChannel

update

Updates to apply to the CalculatedChannel.

TYPE: CalculatedChannelUpdate | dict

user_notes

User notes for the update.

TYPE: str | None DEFAULT: None

RETURNS DESCRIPTION
CalculatedChannel

The updated CalculatedChannel.