-
Notifications
You must be signed in to change notification settings - Fork 26
FGA_BASE: adding base types and module registraiton #556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
swaroopAkkineniWorkos
wants to merge
20
commits into
main
Choose a base branch
from
ENT-5224-python-sdk-for-fga-worktree-fuck-around
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
ab35617
adding base types and module registraiton
swaroopAkkineniWorkos 5f6892d
moar
swaroopAkkineniWorkos 0bc40fb
lol
swaroopAkkineniWorkos 526eb7d
lol
swaroopAkkineniWorkos 13dad51
nits for re-dupe OrganizationMembershipStatus
swaroopAkkineniWorkos ff239c7
Format
swaroopAkkineniWorkos a5823c6
adding AUTHORIZATION_RESOURCES_PATH to base
swaroopAkkineniWorkos 8dd434f
FGA_1: create/delete/get/update resource (#563)
swaroopAkkineniWorkos fe59018
FGA_2: listResources(), get/update/delete resource_by_external_id (#569)
swaroopAkkineniWorkos a50f5d5
FGA_3: check() (#568)
swaroopAkkineniWorkos 3eca552
remove organization_name for list
swaroopAkkineniWorkos fa170f0
casade
swaroopAkkineniWorkos 035f1c3
lol
swaroopAkkineniWorkos 8fbbc5f
moar
swaroopAkkineniWorkos 7342ad4
Create
swaroopAkkineniWorkos 3f25161
test update
swaroopAkkineniWorkos dfca291
break outp
swaroopAkkineniWorkos 5f72f0d
lol
swaroopAkkineniWorkos a7c6d28
moar
swaroopAkkineniWorkos 0111cde
moar
swaroopAkkineniWorkos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,29 @@ | ||
| from workos.types.authorization.access_check_response import AccessCheckResponse | ||
| from workos.types.authorization.environment_role import ( | ||
| EnvironmentRole, | ||
| EnvironmentRoleList, | ||
| ) | ||
| from workos.types.authorization.organization_membership import ( | ||
| AuthorizationOrganizationMembership, | ||
| ) | ||
| from workos.types.authorization.organization_role import ( | ||
| OrganizationRole, | ||
| OrganizationRoleEvent, | ||
| OrganizationRoleList, | ||
| ) | ||
| from workos.types.authorization.permission import Permission | ||
| from workos.types.authorization.resource import Resource | ||
| from workos.types.authorization.resource_identifier import ( | ||
| ResourceIdentifier, | ||
| ResourceIdentifierByExternalId, | ||
| ResourceIdentifierById, | ||
| ) | ||
| from workos.types.authorization.role import ( | ||
| Role, | ||
| RoleList, | ||
| ) | ||
| from workos.types.authorization.role_assignment import ( | ||
| RoleAssignment, | ||
| RoleAssignmentResource, | ||
| RoleAssignmentRole, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| from workos.types.workos_model import WorkOSModel | ||
|
|
||
|
|
||
| class AccessCheckResponse(WorkOSModel): | ||
| authorized: bool |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| from workos.types.user_management.organization_membership import ( | ||
| BaseOrganizationMembership, | ||
| ) | ||
|
|
||
| AuthorizationOrganizationMembership = BaseOrganizationMembership |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| from typing import Literal, Optional | ||
|
|
||
| from workos.types.workos_model import WorkOSModel | ||
|
|
||
|
|
||
| class Resource(WorkOSModel): | ||
| """Representation of an Authorization Resource.""" | ||
|
|
||
| object: Literal["authorization_resource"] | ||
| id: str | ||
| external_id: str | ||
| name: str | ||
| description: Optional[str] = None | ||
| resource_type_slug: str | ||
| organization_id: str | ||
| parent_resource_id: Optional[str] = None | ||
| created_at: str | ||
| updated_at: str |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| from typing import Union | ||
|
|
||
| from typing_extensions import TypedDict | ||
|
|
||
|
|
||
| class ResourceIdentifierById(TypedDict): | ||
| resource_id: str | ||
|
|
||
|
|
||
| class ResourceIdentifierByExternalId(TypedDict): | ||
| resource_external_id: str | ||
| resource_type_slug: str | ||
|
|
||
|
|
||
| ResourceIdentifier = Union[ResourceIdentifierById, ResourceIdentifierByExternalId] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| from typing import Literal | ||
|
|
||
| from workos.types.workos_model import WorkOSModel | ||
|
|
||
|
|
||
| class RoleAssignmentRole(WorkOSModel): | ||
| slug: str | ||
|
|
||
|
|
||
| class RoleAssignmentResource(WorkOSModel): | ||
| id: str | ||
| external_id: str | ||
| resource_type_slug: str | ||
|
|
||
|
|
||
| class RoleAssignment(WorkOSModel): | ||
| object: Literal["role_assignment"] | ||
| id: str | ||
| role: RoleAssignmentRole | ||
| resource: RoleAssignmentResource | ||
| created_at: str | ||
| updated_at: str |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 14 additions & 11 deletions
25
src/workos/types/user_management/organization_membership.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,29 @@ | ||
| from typing import Any, Literal, Mapping, Optional, Sequence | ||
| from typing_extensions import TypedDict | ||
|
|
||
| from workos.types.user_management.organization_membership_status import ( | ||
| OrganizationMembershipStatus, | ||
| ) | ||
| from workos.types.workos_model import WorkOSModel | ||
| from workos.typing.literals import LiteralOrUntyped | ||
|
|
||
| OrganizationMembershipStatus = Literal["active", "inactive", "pending"] | ||
|
|
||
| class BaseOrganizationMembership(WorkOSModel): | ||
| object: Literal["organization_membership"] | ||
| id: str | ||
| user_id: str | ||
| organization_id: str | ||
| status: LiteralOrUntyped[OrganizationMembershipStatus] | ||
| custom_attributes: Optional[Mapping[str, Any]] = None | ||
| created_at: str | ||
| updated_at: str | ||
|
|
||
|
|
||
| class OrganizationMembershipRole(TypedDict): | ||
| slug: str | ||
|
|
||
|
|
||
| class OrganizationMembership(WorkOSModel): | ||
| """Representation of an WorkOS Organization Membership.""" | ||
|
|
||
| object: Literal["organization_membership"] | ||
| id: str | ||
| user_id: str | ||
| organization_id: str | ||
| class OrganizationMembership(BaseOrganizationMembership): | ||
| role: OrganizationMembershipRole | ||
| roles: Optional[Sequence[OrganizationMembershipRole]] = None | ||
| status: LiteralOrUntyped[OrganizationMembershipStatus] | ||
| custom_attributes: Mapping[str, Any] | ||
| created_at: str | ||
| updated_at: str |
3 changes: 3 additions & 0 deletions
3
src/workos/types/user_management/organization_membership_status.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from typing import Literal | ||
|
|
||
| OrganizationMembershipStatus = Literal["active", "inactive", "pending"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,6 +123,8 @@ def _prepare_request( | |
| json: JsonType = None, | ||
| headers: HeadersType = None, | ||
| exclude_default_auth_headers: bool = False, | ||
| force_include_body: bool = False, | ||
| exclude_none: bool = True, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add docstring for this argument? |
||
| ) -> PreparedRequest: | ||
| """Executes a request against the WorkOS API. | ||
|
|
||
|
|
@@ -133,7 +135,8 @@ def _prepare_request( | |
| method Optional[str]: One of the supported methods as defined by the REQUEST_METHOD_X constants | ||
| params Optional[dict]: Query params or body payload to be added to the request | ||
| headers Optional[dict]: Custom headers to be added to the request | ||
| token Optional[str]: Bearer token | ||
| exclude_default_auth_headers (bool): If True, excludes default auth headers from the request | ||
| force_include_body (bool): If True, allows sending a body in a bodyless request (used for DELETE requests) | ||
|
|
||
| Returns: | ||
| dict: Response from WorkOS | ||
|
|
@@ -149,19 +152,19 @@ def _prepare_request( | |
| REQUEST_METHOD_GET, | ||
| ] | ||
|
|
||
| if bodyless_http_method and json is not None: | ||
| if bodyless_http_method and json is not None and not force_include_body: | ||
| raise ValueError(f"Cannot send a body with a {parsed_method} request") | ||
|
|
||
| # Remove any parameters that are None | ||
| if params is not None: | ||
| params = {k: v for k, v in params.items() if v is not None} | ||
|
|
||
| # Remove any body values that are None | ||
| if json is not None and isinstance(json, Mapping): | ||
| if exclude_none and json is not None and isinstance(json, Mapping): | ||
| json = {k: v for k, v in json.items() if v is not None} | ||
|
|
||
| # We'll spread these return values onto the HTTP client request method | ||
| if bodyless_http_method: | ||
| if bodyless_http_method and not force_include_body: | ||
| return { | ||
| "method": parsed_method, | ||
| "url": url, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's risky to duplicate this if it already exists in another package. Could drift from the other types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually broke it out out organization_membership.py into it's own file so it could be imported as the single source of truth