Skip to content

Comments

FGA_5: list_resources_for_membership, list_memberships_for_resource, list_memberships_for_resource_by_external_id#571

Open
swaroopAkkineniWorkos wants to merge 5 commits intoENT-5224-python-sdk-for-fga-worktree-fuck-aroundfrom
fga-pr5
Open

FGA_5: list_resources_for_membership, list_memberships_for_resource, list_memberships_for_resource_by_external_id#571
swaroopAkkineniWorkos wants to merge 5 commits intoENT-5224-python-sdk-for-fga-worktree-fuck-aroundfrom
fga-pr5

Conversation

@swaroopAkkineniWorkos
Copy link

…list_memberships_for_resource_by_external_id

Description

Documentation

Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.

[ ] Yes

If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.

…list_memberships_for_resource_by_external_id
@swaroopAkkineniWorkos
Copy link
Author

@greptile review

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Comment on lines +996 to +999
limit: int = DEFAULT_LIST_RESPONSE_LIMIT,
before: Optional[str] = None,
after: Optional[str] = None,
order: PaginationOrder = "desc",

Choose a reason for hiding this comment

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

Would ideally like to move this to a PAginationOptions object, but want to keep things consistence with above

@workos workos deleted a comment from greptile-apps bot Feb 23, 2026
@swaroopAkkineniWorkos
Copy link
Author

@greptile re-review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 23, 2026

Greptile Summary

Added three new authorization methods to query the relationship between organization memberships and resources. The implementation follows existing SDK patterns with proper sync/async support, type-safe parameter handling, and auto-pagination. All three methods (list_resources_for_membership, list_memberships_for_resource, list_memberships_for_resource_by_external_id) are consistently implemented across both sync and async variants.

Key additions:

  • list_resources_for_membership: Lists resources accessible by a membership with a given permission, scoped to a parent resource
  • list_memberships_for_resource: Lists memberships that have access to a resource with a given permission
  • list_memberships_for_resource_by_external_id: Same as above but uses external ID for resource lookup
  • New ParentResourceIdentifier union type supporting both ID-based and external ID-based parent resource references
  • Comprehensive test coverage including pagination tests for all methods

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation follows established patterns in the codebase, includes comprehensive test coverage, properly handles both sync and async execution, and correctly implements pagination. No security issues, logic errors, or code quality concerns were identified.
  • No files require special attention

Important Files Changed

Filename Overview
src/workos/authorization.py Added three new list methods for querying resources and memberships with proper sync/async implementations, pagination support, and consistent API patterns
src/workos/types/authorization/resource_identifier.py New type definitions for parent resource identifiers supporting both ID-based and external ID-based lookups
src/workos/types/authorization/init.py Added exports for new ParentResourceIdentifier types to make them publicly accessible
tests/test_authorization_resource_memberships.py Comprehensive test coverage for all three new methods including edge cases, pagination, and both sync/async implementations

Sequence Diagram

sequenceDiagram
    participant Client
    participant SDK
    participant API

    Note over Client,API: Query Resources by Membership
    Client->>SDK: list_resources_for_membership(membership_id, permission, parent_resource)
    SDK->>API: GET /authorization/organization_memberships/{id}/resources
    API-->>SDK: List of accessible resources
    SDK-->>Client: WorkOSListResource[Resource]

    Note over Client,API: Query Memberships by Resource ID
    Client->>SDK: list_memberships_for_resource(resource_id, permission, assignment?)
    SDK->>API: GET /authorization/resources/{id}/organization_memberships
    API-->>SDK: List of memberships with access
    SDK-->>Client: WorkOSListResource[Membership]

    Note over Client,API: Query Memberships by External ID
    Client->>SDK: list_memberships_for_resource_by_external_id(org_id, type, external_id, permission)
    SDK->>API: GET /authorization/organizations/{org_id}/resources/{type}/{external_id}/organization_memberships
    API-->>SDK: List of memberships with access
    SDK-->>Client: WorkOSListResource[Membership]
Loading

Last reviewed commit: e9a6975

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

4 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@swaroopAkkineniWorkos swaroopAkkineniWorkos marked this pull request as ready for review February 23, 2026 17:52
@swaroopAkkineniWorkos swaroopAkkineniWorkos requested a review from a team as a code owner February 23, 2026 17:52
@swaroopAkkineniWorkos swaroopAkkineniWorkos requested review from atainter and gjtorikian and removed request for a team February 23, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant