Skip to content

FGA_2: listResources(), get/update/delete resource_by_external_id#569

Merged
swaroopAkkineniWorkos merged 5 commits intoENT-5224-python-sdk-for-fga-worktree-fuck-aroundfrom
fga-pr3
Feb 24, 2026
Merged

FGA_2: listResources(), get/update/delete resource_by_external_id#569
swaroopAkkineniWorkos merged 5 commits intoENT-5224-python-sdk-for-fga-worktree-fuck-aroundfrom
fga-pr3

Conversation

@swaroopAkkineniWorkos
Copy link

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.

@swaroopAkkineniWorkos swaroopAkkineniWorkos changed the base branch from main to ENT-5224-python-sdk-for-fga-worktree-fuck-around February 20, 2026 21:37
@swaroopAkkineniWorkos
Copy link
Author

@greptile review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 21, 2026

Greptile Summary

This PR adds Fine-Grained Authorization (FGA) resource management capabilities by external ID to the Python SDK. The implementation adds four new methods to the Authorization module: get_resource_by_external_id(), update_resource_by_external_id(), delete_resource_by_external_id(), and list_resources().

  • Implements both synchronous and asynchronous variants following the SDK's established dual-client pattern
  • Adds proper type definitions with ResourceListFilters and ResourcesListResource for pagination support
  • Provides comprehensive test coverage using the @pytest.mark.sync_and_async pattern
  • Tests cover URL construction, parameter handling, pagination, cascade delete functionality, and auto-pagination
  • All implementations follow existing code patterns in the repository (URL path construction, parameter handling, HTTP methods)
  • No security issues identified - no sensitive data logging, proper use of PATCH/DELETE methods, consistent with existing patterns

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation strictly follows established SDK patterns for dual sync/async support, uses proper HTTP methods and type definitions, has comprehensive test coverage including edge cases and auto-pagination, and introduces no security concerns or custom instruction violations
  • No files require special attention

Important Files Changed

Filename Overview
src/workos/authorization.py Adds four new resource management methods (get, update, delete, list) by external_id, following established SDK patterns with proper sync/async implementations
tests/test_authorization_resource_external_id.py Comprehensive test coverage for all new resource methods with both sync/async variants, edge cases, and auto-pagination testing

Sequence Diagram

sequenceDiagram
    participant Client
    participant Authorization
    participant HTTPClient
    participant API

    Note over Client,API: Resource Operations by External ID

    Client->>Authorization: get_resource_by_external_id(org_id, type, ext_id)
    Authorization->>HTTPClient: GET /authorization/organizations/{org_id}/resources/{type}/{ext_id}
    HTTPClient->>API: HTTP Request
    API-->>HTTPClient: Resource JSON
    HTTPClient-->>Authorization: Response
    Authorization-->>Client: Resource object

    Client->>Authorization: update_resource_by_external_id(org_id, type, ext_id, name, desc)
    Authorization->>HTTPClient: PATCH /authorization/organizations/{org_id}/resources/{type}/{ext_id}
    HTTPClient->>API: HTTP Request with JSON body
    API-->>HTTPClient: Updated Resource JSON
    HTTPClient-->>Authorization: Response
    Authorization-->>Client: Resource object

    Client->>Authorization: delete_resource_by_external_id(org_id, type, ext_id, cascade_delete)
    Authorization->>HTTPClient: DELETE /authorization/organizations/{org_id}/resources/{type}/{ext_id}
    HTTPClient->>API: HTTP Request with params
    API-->>HTTPClient: 202 Accepted
    HTTPClient-->>Authorization: Response
    Authorization-->>Client: None

    Client->>Authorization: list_resources(org_id, filters, pagination)
    Authorization->>HTTPClient: GET /authorization/organizations/{org_id}/resources
    HTTPClient->>API: HTTP Request with query params
    API-->>HTTPClient: Paginated List JSON
    HTTPClient-->>Authorization: Response
    Authorization-->>Client: WorkOSListResource
Loading

Last reviewed commit: 63f2f60

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

cascade_delete: Optional[bool] = None,
) -> SyncOrAsync[None]: ...

def list_resources(

Choose a reason for hiding this comment

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

Add in search

@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, csrbarber and faroceann and removed request for a team February 23, 2026 17:52
Comment on lines +193 to +200
def delete_resource_by_external_id(
self,
organization_id: str,
resource_type: str,
external_id: str,
*,
cascade_delete: Optional[bool] = None,
) -> SyncOrAsync[None]: ...

Choose a reason for hiding this comment

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

follow pattern in update #563

@swaroopAkkineniWorkos swaroopAkkineniWorkos merged commit fe59018 into ENT-5224-python-sdk-for-fga-worktree-fuck-around Feb 24, 2026
11 checks passed
@swaroopAkkineniWorkos swaroopAkkineniWorkos deleted the fga-pr3 branch February 24, 2026 20:50
@swaroopAkkineniWorkos swaroopAkkineniWorkos restored the fga-pr3 branch February 24, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant