Skip to content

sift_client.resources.access_control.resource_attributes

CLASS DESCRIPTION
ResourceAttributesAPIAsync

High-level API for resource attributes.

ResourceAttributeKeysAPIAsync

High-level API for resource attribute keys.

ResourceAttributeEnumValuesAPIAsync

High-level API for the enum values defined on resource attribute keys.

ResourceAttributeAssignmentsAPIAsync

High-level API for resource attribute assignments.

ATTRIBUTE DESCRIPTION
ResourceLike

ResourceLike module-attribute

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

ResourceAttributesAPIAsync

ResourceAttributesAPIAsync(sift_client: SiftClient)

Bases: ResourceBase

High-level API for resource attributes.

Resource attributes describe the Sift objects an access decision applies to. A resource is the "what" in an access decision.

Create or fetch an attribute key via keys, define enum values via enum_values when the key uses them, then assign a value to resources via assignments. Pass existing Asset, Channel, and Run objects directly, or build a ResourceAttributeEntity from a resource ID.

Initialize the ResourceAttributesAPI.

PARAMETER DESCRIPTION
sift_client

The Sift client to use.

TYPE: SiftClient

ATTRIBUTE DESCRIPTION
keys

Nested keys API. See ResourceAttributeKeysAPIAsync.

TYPE: ResourceAttributeKeysAPIAsync

enum_values

Nested enum values API. See ResourceAttributeEnumValuesAPIAsync.

TYPE: ResourceAttributeEnumValuesAPIAsync

assignments

Nested assignments API. See ResourceAttributeAssignmentsAPIAsync.

TYPE: ResourceAttributeAssignmentsAPIAsync

client

TYPE: SiftClient

grpc_client

TYPE: GrpcClient

rest_client

TYPE: RestClient

keys instance-attribute

Nested keys API. See ResourceAttributeKeysAPIAsync.

enum_values instance-attribute

Nested enum values API. See ResourceAttributeEnumValuesAPIAsync.

assignments instance-attribute

Nested assignments API. See ResourceAttributeAssignmentsAPIAsync.

client property

client: SiftClient

grpc_client property

grpc_client: GrpcClient

rest_client property

rest_client: RestClient

ResourceAttributeKeysAPIAsync

ResourceAttributeKeysAPIAsync(sift_client: SiftClient)

Bases: ResourceBase

High-level API for resource attribute keys.

Accessed as a nested resource via client.access_control.resource_attributes.keys.

Initialize the ResourceAttributeKeysAPI.

PARAMETER DESCRIPTION
sift_client

The Sift client to use.

TYPE: SiftClient

METHOD DESCRIPTION
get

Get a resource attribute key by ID.

list_

List resource attribute keys with optional filtering.

find

Find a single key matching the query. Takes the same arguments as list_.

create

Create a resource attribute key.

get_or_create

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

update

Update a key.

archive

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

unarchive

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

check_archive_impact

Check how many assignments archiving a key would affect.

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

get async

get(*, key_id: str) -> ResourceAttributeKey

Get a resource attribute key by ID.

PARAMETER DESCRIPTION
key_id

The ID of the key.

TYPE: str

RETURNS DESCRIPTION
ResourceAttributeKey

The key.

list_ async

list_(
    *,
    name: str | None = None,
    names: list[str] | None = None,
    name_contains: str | None = None,
    name_regex: str | Pattern | None = None,
    value_type: ResourceAttributeValueType | None = None,
    created_after: datetime | None = None,
    created_before: datetime | None = None,
    description_contains: str | 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.

The service does not yet support filtering keys by modified date or user.

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

value_type

Filter to keys of this value type.

TYPE: ResourceAttributeValueType | None DEFAULT: None

created_after

Filter to keys created after this datetime.

TYPE: datetime | None DEFAULT: None

created_before

Filter to keys created before this datetime.

TYPE: datetime | None DEFAULT: None

description_contains

Substring match on the description.

TYPE: str | 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.

find async

find(**kwargs) -> ResourceAttributeKey | None

Find a single key matching the query. Takes the same arguments as list_.

PARAMETER DESCRIPTION
**kwargs

Keyword arguments to pass to list_.

DEFAULT: {}

RETURNS DESCRIPTION
ResourceAttributeKey | None

The key found, or None if no key matches.

RAISES DESCRIPTION
ValueError

If more than one key matches.

create async

create(
    display_name: str,
    value_type: ResourceAttributeValueType,
    *,
    description: str = "",
) -> ResourceAttributeKey

Create a resource attribute key.

PARAMETER DESCRIPTION
display_name

The human-readable name of the key.

TYPE: str

value_type

The value type of the key.

TYPE: ResourceAttributeValueType

description

Optional description.

TYPE: str DEFAULT: ''

RETURNS DESCRIPTION
ResourceAttributeKey

The created key.

get_or_create async

get_or_create(
    display_name: str,
    value_type: ResourceAttributeValueType,
    *,
    description: str = "",
) -> ResourceAttributeKey

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

PARAMETER DESCRIPTION
display_name

The human-readable name of the key.

TYPE: str

value_type

The value type used if the key is created.

TYPE: ResourceAttributeValueType

description

Optional description used if the key is created.

TYPE: str DEFAULT: ''

RETURNS DESCRIPTION
ResourceAttributeKey

The existing or newly created key.

Note

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

update async

update(
    key: str | ResourceAttributeKey,
    update: ResourceAttributeKeyUpdate | dict,
) -> ResourceAttributeKey

Update a key.

PARAMETER DESCRIPTION
key

The key or key ID to update.

TYPE: str | ResourceAttributeKey

update

Updates to apply to the key.

TYPE: ResourceAttributeKeyUpdate | dict

RETURNS DESCRIPTION
ResourceAttributeKey

The updated key.

archive async

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

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

PARAMETER DESCRIPTION
key

The key or key ID to archive.

TYPE: str | ResourceAttributeKey

RETURNS DESCRIPTION
ResourceAttributeKey

The archived key.

unarchive async

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

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

PARAMETER DESCRIPTION
key

The key or key ID to unarchive.

TYPE: str | ResourceAttributeKey

RETURNS DESCRIPTION
ResourceAttributeKey

The unarchived key.

check_archive_impact async

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

Check how many assignments archiving a key would affect.

PARAMETER DESCRIPTION
key

The key or key ID to check.

TYPE: str | ResourceAttributeKey

RETURNS DESCRIPTION
int

The number of active assignments archiving this key would affect.

ResourceAttributeEnumValuesAPIAsync

ResourceAttributeEnumValuesAPIAsync(
    sift_client: SiftClient,
)

Bases: ResourceBase

High-level API for the enum values defined on resource attribute keys.

Accessed as a nested resource via client.access_control.resource_attributes.enum_values.

Initialize the ResourceAttributeEnumValuesAPI.

PARAMETER DESCRIPTION
sift_client

The Sift client to use.

TYPE: SiftClient

METHOD DESCRIPTION
create

Create a single enum value for a key.

list_

List the enum values defined for a key.

get_or_create

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

archive

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

unarchive

Unarchive an enum value.

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

create async

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

Create a single enum value for a key.

PARAMETER DESCRIPTION
key

The key or key ID the enum value belongs to.

TYPE: str | ResourceAttributeKey

display_name

The human-readable name of the enum value.

TYPE: str

description

Optional description.

TYPE: str DEFAULT: ''

RETURNS DESCRIPTION
ResourceAttributeEnumValue

The created enum value.

list_ async

list_(
    key: str | ResourceAttributeKey,
    *,
    name: str | None = None,
    names: list[str] | None = None,
    name_contains: str | None = None,
    name_regex: str | Pattern | None = None,
    created_after: datetime | None = None,
    created_before: datetime | 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.

The service does not yet support filtering enum values by description, modified date, or user.

PARAMETER DESCRIPTION
key

The key or key ID to list enum values for.

TYPE: str | ResourceAttributeKey

name

Exact display name of the enum value.

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

created_after

Filter to enum values created after this datetime.

TYPE: datetime | None DEFAULT: None

created_before

Filter to enum values created before this datetime.

TYPE: datetime | None DEFAULT: None

include_archived

If True, include archived enum values.

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 enum values to return.

TYPE: int | None DEFAULT: None

page_size

Results to fetch per request.

TYPE: int | None DEFAULT: None

RETURNS DESCRIPTION
list[ResourceAttributeEnumValue]

The matching enum values.

get_or_create async

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

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

PARAMETER DESCRIPTION
key

The key or key ID the enum values belong to.

TYPE: str | ResourceAttributeKey

names

Display names of the enum values to get or create.

TYPE: list[str]

RETURNS DESCRIPTION
list[ResourceAttributeEnumValue]

The enum values, in the same order as names.

archive async

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

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

PARAMETER DESCRIPTION
enum_value

The enum value or enum value ID to archive.

TYPE: str | ResourceAttributeEnumValue

replacement

Optional enum value or enum value ID that existing assignments are migrated to.

TYPE: str | ResourceAttributeEnumValue | None DEFAULT: None

RETURNS DESCRIPTION
int

The number of assignments migrated.

unarchive async

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

Unarchive an enum value.

PARAMETER DESCRIPTION
enum_value

The enum value or enum value ID to unarchive.

TYPE: str | ResourceAttributeEnumValue

RETURNS DESCRIPTION
ResourceAttributeEnumValue

The unarchived enum value.

ResourceAttributeAssignmentsAPIAsync

ResourceAttributeAssignmentsAPIAsync(
    sift_client: SiftClient,
)

Bases: ResourceBase

High-level API for resource attribute assignments.

Accessed as a nested resource via client.access_control.resource_attributes.assignments.

Initialize the ResourceAttributeAssignmentsAPI.

PARAMETER DESCRIPTION
sift_client

The Sift client to use.

TYPE: SiftClient

METHOD DESCRIPTION
create

Assign a key's value to resources.

get

Get a single assignment by ID.

list_

List resource attribute assignments.

archive

Batch archive assignments.

unarchive

Batch unarchive assignments.

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

create async

create(
    key: str | ResourceAttributeKey,
    resources: list[
        ResourceAttributeEntity | Asset | Channel | Run
    ],
    *,
    value: ResourceAttributeValueLike,
) -> list[ResourceAttributeAssignment]

Assign a key's value to resources.

PARAMETER DESCRIPTION
key

The key or key ID to assign. Its value_type determines how value is interpreted.

TYPE: str | ResourceAttributeKey

resources

Resources to assign to. Pass Asset, Channel, or Run objects, or ResourceAttributeEntity (via for_asset / for_channel / for_run) when you only have a resource ID.

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 resource; for ENUM, a single enum value; for BOOLEAN, a bool; for NUMBER, an int.

TYPE: ResourceAttributeValueLike

RETURNS DESCRIPTION
list[ResourceAttributeAssignment]

The created assignments, one per enum value per resource for

list[ResourceAttributeAssignment]

SET_OF_ENUM keys.

get async

get(*, assignment_id: str) -> ResourceAttributeAssignment

Get a single assignment by ID.

PARAMETER DESCRIPTION
assignment_id

The ID of the assignment.

TYPE: str

RETURNS DESCRIPTION
ResourceAttributeAssignment

The assignment.

list_ async

list_(
    *,
    key: str | ResourceAttributeKey | None = None,
    resource: ResourceAttributeEntity
    | Asset
    | Channel
    | Run
    | None = None,
    created_after: datetime | None = None,
    created_before: datetime | None = None,
    created_by: str | 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[ResourceAttributeAssignment]

List resource attribute assignments.

For SET_OF_ENUM keys, each enum value is returned as its own assignment.

PARAMETER DESCRIPTION
key

Filter to assignments of this key.

TYPE: str | ResourceAttributeKey | None DEFAULT: None

resource

Filter to assignments on this resource. Cannot be combined with the other filter arguments. Pass a resource object or ResourceAttributeEntity.

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

created_after

Filter to assignments created after this datetime.

TYPE: datetime | None DEFAULT: None

created_before

Filter to assignments created before this datetime.

TYPE: datetime | None DEFAULT: None

created_by

Filter to assignments created by this user ID.

TYPE: str | 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

RETURNS DESCRIPTION
list[ResourceAttributeAssignment]

The matching assignments.

RAISES DESCRIPTION
ValueError

If resource is combined with other filter arguments, which the by-resource listing does not support.

archive async

archive(
    assignments: list[str | ResourceAttributeAssignment],
) -> None

Batch archive assignments.

PARAMETER DESCRIPTION
assignments

The assignments or assignment IDs to archive.

TYPE: list[str | ResourceAttributeAssignment]

unarchive async

unarchive(
    assignments: list[str | ResourceAttributeAssignment],
) -> None

Batch unarchive assignments.

PARAMETER DESCRIPTION
assignments

The assignments or assignment IDs to unarchive.

TYPE: list[str | ResourceAttributeAssignment]