Skip to content

Commit d5d5665

Browse files
chore(hybrid-cloud): Adds Organization RPC method to query orgs by scope (#60045)
1 parent 1f787a5 commit d5d5665

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/sentry/services/hybrid_cloud/organization/impl.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ def get_org_by_slug(
117117
except Organization.DoesNotExist:
118118
return None
119119

120+
def get_organizations_by_user_and_scope(
121+
self, *, region_name: str, user: RpcUser, scope: str
122+
) -> List[RpcOrganization]:
123+
organizations = Organization.objects.get_for_user(user=user, scope=scope)
124+
return list(map(serialize_rpc_organization, organizations))
125+
120126
def get_default_organization(self) -> RpcOrganization:
121127
return serialize_rpc_organization(Organization.get_default())
122128

src/sentry/services/hybrid_cloud/organization/service.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@ def get_org_by_slug(
9292
"""
9393
pass
9494

95+
@regional_rpc_method(resolve=ByRegionName())
96+
@abstractmethod
97+
def get_organizations_by_user_and_scope(
98+
self, *, region_name: str, user: RpcUser, scope: str
99+
) -> List[RpcOrganization]:
100+
"""
101+
Fetches organizations for the given user, with the given organization member scope.
102+
"""
103+
pass
104+
95105
@regional_rpc_method(resolve=ByOrganizationId())
96106
@abstractmethod
97107
def update_flags(self, *, organization_id: int, flags: RpcOrganizationFlagsUpdate) -> None:

0 commit comments

Comments
 (0)