Skip to content

feat: fga adding base types and module registraiton#556

Open
swaroopAkkineniWorkos wants to merge 43 commits intomainfrom
ENT-5224-python-sdk-for-fga-worktree-fuck-around
Open

feat: fga adding base types and module registraiton#556
swaroopAkkineniWorkos wants to merge 43 commits intomainfrom
ENT-5224-python-sdk-for-fga-worktree-fuck-around

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.

@linear
Copy link

linear bot commented Feb 19, 2026

@swaroopAkkineniWorkos swaroopAkkineniWorkos changed the title adding base types and module registraiton FGA_BASE: adding base types and module registraiton Feb 20, 2026
@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.

19 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

from workos.types.workos_model import WorkOSModel
from workos.typing.literals import LiteralOrUntyped

OrganizationMembershipStatus = Literal["active", "inactive", "pending"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicated OrganizationMembershipStatus literal

This exact same Literal["active", "inactive", "pending"] type alias is already defined in src/workos/types/user_management/organization_membership.py:7. Consider importing from a shared location or re-exporting from one module to the other to avoid the definitions drifting apart over time.

Choose a reason for hiding this comment

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

Just pushed up a change where I moved "OrganizationMembershipStatus" to it's own file to be imported

@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
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.

17 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@swaroopAkkineniWorkos
Copy link
Author

Change branch name before merging

if cascade_delete is not None:
await self._http_client.delete_with_body(
f"{AUTHORIZATION_RESOURCES_PATH}/{resource_id}",
json={"cascade_delete": cascade_delete},
Copy link
Contributor

Choose a reason for hiding this comment

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

This adds cascade_delete to the body, but I believe it should be passed as a query param instead. Which is what delete_resource_by_external_id does here

Choose a reason for hiding this comment

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

updated to be a param

Comment on lines +1177 to +1178
if description is not None:
json["description"] = description
Copy link
Contributor

Choose a reason for hiding this comment

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

Does description here need the same treatment as in update_resource?


# --- create_resource ---

def test_create_resource_required_fields_only(
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we update this test since parent isn't a required field?

Choose a reason for hiding this comment

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

updated and added a test

id: str
user_id: str
organization_id: str
organization_name: str
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like we don't include organization_name in the responses where this gets used. For instance listOrganizationMembershipsForResource calls serializeBase, which doesn't include organization_name.

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

@greptile plz re-review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 2, 2026

Greptile Summary

This PR adds foundational types and CRUD operations for Fine-Grained Authorization (FGA) resources to the WorkOS Python SDK. The implementation introduces resource management capabilities with support for both ID-based and external-ID-based operations.

Key Changes:

  • Added complete CRUD operations for authorization resources (get_resource, create_resource, update_resource, delete_resource, list_resources)
  • Implemented external ID-based resource operations for more flexible resource identification
  • Added check method for permission-based access control
  • Enhanced HTTP client to support exclude_none parameter for precise control over null value handling in API requests
  • Introduced delete_with_body method (though not used in this PR, likely for future functionality)
  • Refactored OrganizationMembership to extract BaseOrganizationMembership for code reuse across modules
  • Comprehensive test coverage for all new functionality

Implementation Quality:

  • Uses the UNSET pattern correctly to distinguish between "don't update field" vs "set field to null"
  • Proper handling of optional parent resources (by ID or external ID)
  • Well-tested with both sync and async implementations
  • Type-safe with Pydantic models and proper TypedDict usage

Minor Issue:

  • TODO comment on line 56 of authorization.py should be resolved

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk
  • The implementation is well-structured with comprehensive test coverage for all new functionality. The code follows established patterns in the codebase and properly handles edge cases. The only issue is a minor TODO comment that should be addressed.
  • Pay attention to src/workos/authorization.py due to the TODO comment on line 56

Important Files Changed

Filename Overview
src/workos/authorization.py Adds resource CRUD operations and access check functionality; contains TODO comment on line 56
src/workos/utils/http_client.py Adds exclude_none parameter and delete_with_body method for enhanced HTTP request handling
src/workos/utils/_base_http_client.py Adds force_include_body and exclude_none parameters to support DELETE with body and optional null values
src/workos/types/authorization/authorization_resource.py Defines AuthorizationResource model with proper typing and optional fields

Last reviewed commit: 954bb37

Comment on lines +56 to +59
# TODO RENAME
ResourcesListResource = WorkOSListResource[
AuthorizationResource, ResourceListFilters, ListMetadata
]
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO comment needs resolution

Either rename ResourcesListResource to something more descriptive (like AuthorizationResourceList) or remove the TODO if the current name is acceptable.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Choose a reason for hiding this comment

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

updated and changed name

Copy link
Contributor

@atainter atainter left a comment

Choose a reason for hiding this comment

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

Looks good to me. Should probably get a review from python code owners as well

@swaroopAkkineniWorkos swaroopAkkineniWorkos changed the title FGA_BASE: adding base types and module registraiton feat: fga adding base types and module registraiton Mar 4, 2026
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.

3 participants