Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

UN-2891 [FEAT] Enable organization-level sharing for API deployments (#1631)

Rahul Johny7db8766938e0
diff --git a/backend/api_v2/api_deployment_views.py b/backend/api_v2/api_deployment_views.py
index 4767cb1a6..dc4d77108 100644
--- a/backend/api_v2/api_deployment_views.py
+++ b/backend/api_v2/api_deployment_views.py
@@ -6,7 +6,7 @@ from typing import Any
from configuration.models import Configuration
from django.db.models import QuerySet
from django.http import HttpResponse
-from permissions.permission import IsOwner, IsOwnerOrSharedUser
+from permissions.permission import IsOwner, IsOwnerOrSharedUserOrSharedToOrg
from prompt_studio.prompt_studio_registry_v2.models import PromptStudioRegistry
from rest_framework import serializers, status, views, viewsets
from rest_framework.decorators import action
@@ -198,7 +198,7 @@ class APIDeploymentViewSet(viewsets.ModelViewSet):
def get_permissions(self) -> list[Any]:
if self.action in ["destroy", "partial_update", "update"]:
return [IsOwner()]
- return [IsOwnerOrSharedUser()]
+ return [IsOwnerOrSharedUserOrSharedToOrg()]
def get_queryset(self) -> QuerySet | None:
queryset = APIDeployment.objects.for_user(self.request.user)
diff --git a/backend/api_v2/models.py b/backend/api_v2/models.py
index addc1d980..437015c7f 100644
--- a/backend/api_v2/models.py
+++ b/backend/api_v2/models.py
@@ -29,12 +29,14 @@ class APIDeploymentModelManager(DefaultOrganizationManagerMixin, models.Manager)
"""Filter API deployments that the user can access:
- API deployments created by the user
- API deployments shared with the user
+ - API deployments shared with the entire organization
"""
from django.db.models import Q
return self.filter(
Q(created_by=user) # Owned by user
| Q(shared_users=user) # Shared with user
+ | Q(shared_to_org=True) # Shared to entire organization
).distinct()
diff --git a/frontend/src/components/deployments/api-deployment/ApiDeployment.jsx b/frontend/src/components/deployments/api-deployment/ApiDeployment.jsx
index 99235ddca..f580a46e7 100644
--- a/frontend/src/components/deployments/api-deployment/ApiDeployment.jsx
+++ b/frontend/src/components/deployments/api-deployment/ApiDeployment.jsx
@@ -567,7 +567,7 @@ function ApiDeployment() {
loading={isLoadingShare}
allUsers={allUsers}
onApply={onShare}
- isSharableToOrg={false}
+ isSharableToOrg={true}
/>
</>
);