Skip to content

python(refactor): group access control APIs under client.access_control#666

Merged
wei-qlu merged 22 commits into
mainfrom
eng-12537-group-the-access-control-client-surface-under-a-single
Jul 11, 2026
Merged

python(refactor): group access control APIs under client.access_control#666
wei-qlu merged 22 commits into
mainfrom
eng-12537-group-the-access-control-client-surface-under-a-single

Conversation

@wei-qlu

@wei-qlu wei-qlu commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Groups access-control APIs under:

client.access_control
client.async_.access_control

This keeps resource and principal attributes together under one access-control surface, with room for future APIs.

  • Added sync and async access_control namespaces.
  • Moved resource and principal attribute APIs under client.access_control.
  • Improved assignment ergonomics:
    • assign() accepts key objects or key IDs.
    • Resource assignments accept resource objects, raw resource IDs, or ResourceAttributeEntity.
    • Principal assignments accept user IDs, and user emails for USER principals.

Example

key = client.access_control.resource_attributes.get_or_create_key(
    "licenses",
    ResourceAttributeKeyType.SET_OF_ENUM,
)
licenses = key.get_or_create_enum_values(["LICENSE_A", "LICENSE_B"])
key.assign_to([channel], value=licenses)

Validation

  • Unit tests and Manual QA of creating resource and principal attributes through the new namespace.

@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Python docs preview: https://sift-stack.github.io/sift/python/pr-666/

Deployed from 4db0c3b. The link may take up to a minute to become live as GitHub Pages propagates.

@wei-qlu
wei-qlu marked this pull request as ready for review July 1, 2026 00:39
Comment thread python/lib/sift_client/resources/access_control/principal_attributes.py Outdated
Comment thread python/lib/sift_client/resources/access_control/principal_attributes.py Outdated
Comment thread python/lib/sift_client/resources/access_control/principal_attributes.py Outdated
Comment thread python/lib/sift_client/resources/access_control/resource_attributes.py Outdated
Comment thread python/lib/sift_client/sift_types/principal_attribute.py
Comment thread python/lib/sift_client/resources/access_control/__init__.py
Comment thread python/lib/sift_client/resources/access_control/resource_attributes.py Outdated
Comment thread python/lib/sift_client/sift_types/resource_attribute.py Outdated
Comment thread python/lib/sift_client/sift_types/resource_attribute.py
Comment thread python/lib/sift_client/sift_types/resource_attribute.py Outdated
@alexluck-sift
alexluck-sift self-requested a review July 1, 2026 17:35
@wei-qlu
wei-qlu requested a review from alexluck-sift July 10, 2026 22:54

@alexluck-sift alexluck-sift left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed after the latest round. All my earlier feedback is addressed, and I ran a full audit of the current surface: the touched-area unit tests (151) pass, and mypy and pyright are clean. Sync/async parity, exports, and client wiring all check out. Overall the PR is in strong shape.

Two items with real user impact are inline as requested changes (both small). The rest are non-blocking and prefixed as such.

One extra note, non-blocking, on test coverage: the suite passes but a few branches are unexercised. A NUMBER key given a bool, a SET_OF_ENUM key given a scalar, the falsy numeric value 0 (only 5 is tested), the modified_after filter, and an assertion that UNSPECIFIED stays out of the public enums. Cheap to add and they guard real edges.

Comment thread python/lib/sift_client/resources/users.py Outdated
Comment thread python/lib/sift_client/resources/users.py Outdated
Comment thread python/CHANGELOG.md Outdated
Comment thread python/lib/sift_client/sift_types/principal_attribute.py Outdated
Comment thread python/lib/sift_client/resources/access_control/_common.py
Comment thread python/lib/sift_client/sift_types/principal_attribute.py
@wei-qlu
wei-qlu requested a review from alexluck-sift July 11, 2026 00:08
@wei-qlu
wei-qlu merged commit 03b3c37 into main Jul 11, 2026
26 checks passed
@wei-qlu
wei-qlu deleted the eng-12537-group-the-access-control-client-surface-under-a-single branch July 11, 2026 00:12
alexluck-sift pushed a commit that referenced this pull request Jul 11, 2026
Bump version to 0.19.0 and update the changelog for the PRs merged
since v0.18.0: ABAC attributes (#646), get_data cache improvements
(#650), pytest docstring cleaning (#658), ULog data imports (#663),
access control API grouping (#666), report templates (#672),
download_file extra headers (#677), and the get_data pagination fix
plus progress bars (#678).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5U49rrpvQm5bPbvEjR4xr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants