Skip to content

sift_client.resources.resource_attributes

CLASS DESCRIPTION
ResourceAttributesAPIAsync

High-level API for resource attributes (ABAC).

ATTRIBUTE DESCRIPTION
ASSIGN_BATCH_SIZE

EntityLike

ASSIGN_BATCH_SIZE module-attribute

ASSIGN_BATCH_SIZE = 1000

EntityLike module-attribute

EntityLike = Union[
    ResourceAttributeEntity, Asset, Channel, Run
]

ResourceAttributesAPIAsync

ResourceAttributesAPIAsync(sift_client: SiftClient)

Bases: ResourceBase

High-level API for resource attributes (ABAC).

Resource attributes assign attribute keys to Sift entities (assets, channels, runs). The attribute key is the entry point: enum values and assignments are managed through methods on a key, or through the corresponding methods here.

Initialize the ResourceAttributesAPI.

PARAMETER DESCRIPTION
sift_client

The Sift client to use.

TYPE: SiftClient

METHOD DESCRIPTION
archive_assignments

Batch archive assignments.

archive_enum_value

Archive an enum value, migrating existing assignments to a replacement.

archive_key

Archive a key. Cascades to its enum values and assignments.

assign

Assign a value to entities for a key.

check_key_archive_impact

Return the number of active assignments archiving this key would affect.

create_enum_value

Create a single enum value for a key.

create_key

Create a resource attribute key.

find_key

Find a single key matching the query. Raises if more than one matches.

get_assignment

Get a single assignment by ID.

get_key

Get a resource attribute key by ID.

get_or_create_enum_values

Get enum values for a key by name, creating any that don't exist.

get_or_create_key

Get a key by display name, creating it if it does not exist.

list_assignments

List resource attribute assignments.

list_enum_values

List the enum values defined for a key.

list_keys

List resource attribute keys with optional filtering.

unarchive_assignments

Batch unarchive assignments.

unarchive_enum_value

Unarchive an enum value.

unarchive_key

Unarchive a key. Does not restore its cascaded enum values or assignments.

update_key

Update a key's display name or description.

ATTRIBUTE DESCRIPTION
client

TYPE: SiftClient

grpc_client

TYPE: GrpcClient

rest_client

TYPE: RestClient

client property

client: SiftClient

grpc_client property

grpc_client: GrpcClient

rest_client property

rest_client: RestClient

archive_assignments async

archive_assignments(
    assignments: list[str | ResourceAttribute],
) -> None

Batch archive assignments.

archive_enum_value async

archive_enum_value(
    enum_value: str | ResourceAttributeEnumValue,
    *,
    replacement: str
    | ResourceAttributeEnumValue
    | None = None,
) -> int

Archive an enum value, migrating existing assignments to a replacement.

Returns the number of assignments migrated.

archive_key async

archive_key(
    key: str | ResourceAttributeKey,
) -> ResourceAttributeKey

Archive a key. Cascades to its enum values and assignments.

assign async

assign(
    key: ResourceAttributeKey,
    entities: list[
        ResourceAttributeEntity | Asset | Channel | Run
    ],
    *,
    value: Any,
) -> list[ResourceAttribute]

Assign a value to entities for a key.

PARAMETER DESCRIPTION
key

The key to assign. Its key_type determines how value is interpreted.

TYPE: ResourceAttributeKey

entities

Entities to assign to (ResourceAttributeEntity, Asset, Channel, or Run).

TYPE: list[ResourceAttributeEntity | Asset | Channel | Run]

value

For SET_OF_ENUM, a list of enum values (or their IDs) that becomes the full set on each entity; for ENUM, a single enum value; for BOOLEAN, a bool; for NUMBER, an int.

TYPE: Any

RETURNS DESCRIPTION
list[ResourceAttribute]

The created assignments.

check_key_archive_impact async

check_key_archive_impact(
    key: str | ResourceAttributeKey,
) -> int

Return the number of active assignments archiving this key would affect.

create_enum_value async

create_enum_value(
    key: str | ResourceAttributeKey,
    display_name: str,
    *,
    description: str = "",
) -> ResourceAttributeEnumValue

Create a single enum value for a key.

create_key async

create_key(
    display_name: str,
    key_type: ResourceAttributeKeyType,
    *,
    description: str = "",
) -> ResourceAttributeKey

Create a resource attribute key.

PARAMETER DESCRIPTION
display_name

The human-readable name of the key.

TYPE: str

key_type

The value type of the key.

TYPE: ResourceAttributeKeyType

description

Optional description.

TYPE: str DEFAULT: ''

RETURNS DESCRIPTION
ResourceAttributeKey

The created key.

find_key async

find_key(**kwargs) -> ResourceAttributeKey | None

Find a single key matching the query. Raises if more than one matches.

get_assignment async

get_assignment(*, assignment_id: str) -> ResourceAttribute

Get a single assignment by ID.

get_key async

get_key(*, key_id: str) -> ResourceAttributeKey

Get a resource attribute key by ID.

get_or_create_enum_values async

get_or_create_enum_values(
    key: str | ResourceAttributeKey, names: list[str]
) -> list[ResourceAttributeEnumValue]

Get enum values for a key by name, creating any that don't exist.

Returns the values in the same order as names.

get_or_create_key async

get_or_create_key(
    display_name: str,
    key_type: ResourceAttributeKeyType,
    *,
    description: str = "",
) -> ResourceAttributeKey

Get a key by display name, creating it if it does not exist.

Note

Display names are not guaranteed unique. If multiple keys share the display name, the first active match is returned.

list_assignments async

list_assignments(
    *,
    key: str | ResourceAttributeKey | None = None,
    entity: ResourceAttributeEntity
    | Asset
    | Channel
    | Run
    | None = None,
    include_archived: bool = False,
    filter_query: str | None = None,
    order_by: str | None = None,
    limit: int | None = None,
    page_size: int | None = None,
) -> list[ResourceAttribute]

List resource attribute assignments.

PARAMETER DESCRIPTION
key

Filter to assignments of this key.

TYPE: str | ResourceAttributeKey | None DEFAULT: None

entity

Filter to assignments on this entity. When set, other filters are ignored.

TYPE: ResourceAttributeEntity | Asset | Channel | Run | None DEFAULT: None

include_archived

If True, include archived assignments.

TYPE: bool DEFAULT: False

filter_query

Explicit CEL query.

TYPE: str | None DEFAULT: None

order_by

Field and direction to order by.

TYPE: str | None DEFAULT: None

limit

Maximum number of assignments to return.

TYPE: int | None DEFAULT: None

page_size

Results to fetch per request.

TYPE: int | None DEFAULT: None

list_enum_values async

list_enum_values(
    key: str | ResourceAttributeKey,
    *,
    name: str | None = None,
    names: list[str] | None = None,
    name_contains: str | None = None,
    name_regex: str | Pattern | None = None,
    include_archived: bool = False,
    filter_query: str | None = None,
    order_by: str | None = None,
    limit: int | None = None,
    page_size: int | None = None,
) -> list[ResourceAttributeEnumValue]

List the enum values defined for a key.

list_keys async

list_keys(
    *,
    name: str | None = None,
    names: list[str] | None = None,
    name_contains: str | None = None,
    name_regex: str | Pattern | None = None,
    key_type: ResourceAttributeKeyType | None = None,
    include_archived: bool = False,
    filter_query: str | None = None,
    order_by: str | None = None,
    limit: int | None = None,
    page_size: int | None = None,
) -> list[ResourceAttributeKey]

List resource attribute keys with optional filtering.

PARAMETER DESCRIPTION
name

Exact display name of the key.

TYPE: str | None DEFAULT: None

names

Display names to filter by.

TYPE: list[str] | None DEFAULT: None

name_contains

Substring match on the display name.

TYPE: str | None DEFAULT: None

name_regex

Regex match on the display name.

TYPE: str | Pattern | None DEFAULT: None

key_type

Filter to keys of this value type.

TYPE: ResourceAttributeKeyType | None DEFAULT: None

include_archived

If True, include archived keys.

TYPE: bool DEFAULT: False

filter_query

Explicit CEL query.

TYPE: str | None DEFAULT: None

order_by

Field and direction to order by.

TYPE: str | None DEFAULT: None

limit

Maximum number of keys to return.

TYPE: int | None DEFAULT: None

page_size

Results to fetch per request.

TYPE: int | None DEFAULT: None

RETURNS DESCRIPTION
list[ResourceAttributeKey]

The matching keys.

unarchive_assignments async

unarchive_assignments(
    assignments: list[str | ResourceAttribute],
) -> None

Batch unarchive assignments.

unarchive_enum_value async

unarchive_enum_value(
    enum_value: str | ResourceAttributeEnumValue,
) -> ResourceAttributeEnumValue

Unarchive an enum value.

unarchive_key async

unarchive_key(
    key: str | ResourceAttributeKey,
) -> ResourceAttributeKey

Unarchive a key. Does not restore its cascaded enum values or assignments.

update_key async

update_key(
    key: str | ResourceAttributeKey,
    *,
    display_name: str | None = None,
    description: str | None = None,
) -> ResourceAttributeKey

Update a key's display name or description.