Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite committed Feb 14, 2024
1 parent cd4b132 commit 509af94
Show file tree
Hide file tree
Showing 25 changed files with 25 additions and 26 deletions.
2 changes: 1 addition & 1 deletion ee/api/billing.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class BillingViewset(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):
serializer_class = BillingSerializer
derive_current_team_from_user_only = True

scope_object = "not_supported"
scope_object = "INTERNAL"

def list(self, request: Request, *args: Any, **kwargs: Any) -> Response:
license = get_cached_instance_license()
Expand Down
2 changes: 1 addition & 1 deletion ee/api/dashboard_collaborator.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class DashboardCollaboratorViewSet(
mixins.DestroyModelMixin,
viewsets.GenericViewSet,
):
scope_object = "not_supported"
scope_object = "INTERNAL"
permission_classes = [CanEditDashboardCollaborator]
pagination_class = None
queryset = DashboardPrivilege.objects.select_related("dashboard").filter(user__is_active=True)
Expand Down
2 changes: 1 addition & 1 deletion ee/api/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class HookViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):
Retrieve, create, update or destroy REST hooks.
"""

scope_object = "not_supported"
scope_object = "INTERNAL"
queryset = Hook.objects.all()
ordering = "-created_at"
serializer_class = HookSerializer
Expand Down
2 changes: 1 addition & 1 deletion ee/api/organization_resource_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class OrganizationResourceAccessViewSet(
mixins.DestroyModelMixin,
viewsets.GenericViewSet,
):
scope_object = "not_supported"
scope_object = "INTERNAL"
permission_classes = [RolePermissions]
serializer_class = OrganizationResourceAccessSerializer
queryset = OrganizationResourceAccess.objects.all()
1 change: 0 additions & 1 deletion frontend/src/scenes/settings/user/personalAPIKeysLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { loaders } from 'kea-loaders'
import api from 'lib/api'
import { CodeSnippet } from 'lib/components/CodeSnippet'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
import { copyToClipboard } from 'lib/utils/copyToClipboard'
import { userLogic } from 'scenes/userLogic'

import { OrganizationBasicType, PersonalAPIKeyType, TeamBasicType } from '~/types'
Expand Down
2 changes: 1 addition & 1 deletion posthog/api/comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class CommentViewSet(TeamAndOrgViewSetMixin, ForbidDestroyModel, viewsets.ModelV
serializer_class = CommentSerializer
pagination_class = CommentPagination
# TODO: Update when fully released
scope_object = "not_supported"
scope_object = "INTERNAL"

def get_queryset(self) -> QuerySet:
queryset = super().get_queryset()
Expand Down
2 changes: 1 addition & 1 deletion posthog/api/data_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


class DataManagementViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):
scope_object = "not_supported"
scope_object = "INTERNAL"

@action(methods=["GET"], url_path="activity", detail=False, required_scopes=["activity_log:read"])
def all_activity(self, request: request.Request, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion posthog/api/documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def preprocess_exclude_path_format(endpoints, **kwargs):
and callback.cls.derive_current_team_from_user_only
):
pass
elif hasattr(callback.cls, "scope_object") and callback.cls.scope_object != "not_supported":
elif hasattr(callback.cls, "scope_object") and callback.cls.scope_object != "INTERNAL":
# If there is an API Scope set then we implictly support it and should have it in the documentation
path = path.replace("{parent_lookup_team_id}", "{project_id}")
path = path.replace("{parent_lookup_", "{")
Expand Down
2 changes: 1 addition & 1 deletion posthog/api/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Meta:


class ElementViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):
scope_object = "not_supported"
scope_object = "INTERNAL"
filter_rewrite_rules = {"team_id": "group__team_id"}

queryset = Element.objects.all()
Expand Down
2 changes: 1 addition & 1 deletion posthog/api/ingestion_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class IngestionWarningsViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):
scope_object = "not_supported"
scope_object = "INTERNAL"

def list(self, request: Request, **kw) -> Response:
start_date = now() - timedelta(days=30)
Expand Down
2 changes: 1 addition & 1 deletion posthog/api/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class IntegrationViewSet(
mixins.DestroyModelMixin,
viewsets.GenericViewSet,
):
scope_object = "not_supported"
scope_object = "INTERNAL"
queryset = Integration.objects.all()
serializer_class = IntegrationSerializer

Expand Down
2 changes: 1 addition & 1 deletion posthog/api/organization_feature_flag.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class OrganizationFeatureFlagView(
viewsets.ViewSet,
mixins.RetrieveModelMixin,
):
scope_object = "not_supported"
scope_object = "INTERNAL"
"""
Retrieves all feature flags for a given organization and key.
"""
Expand Down
2 changes: 1 addition & 1 deletion posthog/api/organization_invite.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class OrganizationInviteViewSet(
mixins.ListModelMixin,
viewsets.GenericViewSet,
):
scope_object = "not_supported"
scope_object = "INTERNAL"
serializer_class = OrganizationInviteSerializer
queryset = OrganizationInvite.objects.all()
lookup_field = "id"
Expand Down
2 changes: 1 addition & 1 deletion posthog/api/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def validate_q(self, value: str):


class SearchViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):
scope_object = "not_supported"
scope_object = "INTERNAL"

def list(self, request: Request, **kw) -> HttpResponse:
# parse query params
Expand Down
2 changes: 1 addition & 1 deletion posthog/api/tagged_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def get_tag(self, obj: TaggedItem) -> str:


class TaggedItemViewSet(TeamAndOrgViewSetMixin, GenericViewSet):
scope_object = "not_supported"
scope_object = "INTERNAL"
serializer_class = TaggedItemSerializer
queryset = Tag.objects.none()

Expand Down
2 changes: 1 addition & 1 deletion posthog/api/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,4 +512,4 @@ def user_permissions(self):

# NOTE: We don't want people managing projects via the "current_organization" concept. Rather specifying the org ID at the top level
class RootTeamViewSet(TeamViewSet):
scope_object = "not_supported"
scope_object = "INTERNAL"
2 changes: 1 addition & 1 deletion posthog/api/uploaded_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def download(request, *args, **kwargs) -> HttpResponse:


class MediaViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):
scope_object = "not_supported"
scope_object = "INTERNAL"
queryset = UploadedMedia.objects.all()
parser_classes = (MultiPartParser, FormParser)

Expand Down
2 changes: 1 addition & 1 deletion posthog/api/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ class UserViewSet(
mixins.ListModelMixin,
viewsets.GenericViewSet,
):
scope_object = "not_supported"
scope_object = "INTERNAL"
throttle_classes = [UserAuthenticationThrottle]
serializer_class = UserSerializer
permission_classes = [IsAuthenticated, APIScopePermission]
Expand Down
2 changes: 1 addition & 1 deletion posthog/models/personal_api_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class PersonalAPIKey(models.Model):

APIScopeObjectOrNotSupported = Literal[
APIScopeObject,
"not_supported",
"INTERNAL",
]


Expand Down
4 changes: 2 additions & 2 deletions posthog/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def get_required_scopes(self, request, view) -> list[str]:

scope_object = self.get_scope_object(request, view)

if scope_object == "not_supported":
if scope_object == "INTERNAL":
raise PermissionDenied(f"This action does not support Personal API Key access")

read_actions = getattr(view, "scope_object_read_actions", self.read_actions)
Expand All @@ -341,7 +341,7 @@ def get_required_scopes(self, request, view) -> list[str]:
return [f"{scope_object}:read"]

# If we get here this typically means an action was called without a required scope
# It is essentially "not_supported"
# It is essentially "INTERNAL"
raise PermissionDenied(f"This action does not support Personal API Key access")

def get_scope_object(self, request, view) -> APIScopeObjectOrNotSupported:
Expand Down
2 changes: 1 addition & 1 deletion posthog/warehouse/api/external_data_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Meta:


class ExternalDataSchemaViewset(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):
scope_object = "not_supported"
scope_object = "INTERNAL"
queryset = ExternalDataSchema.objects.all()
serializer_class = ExternalDataSchemaSerializer
filter_backends = [filters.SearchFilter]
Expand Down
2 changes: 1 addition & 1 deletion posthog/warehouse/api/external_data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class ExternalDataSourceViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):
Create, Read, Update and Delete External data Sources.
"""

scope_object = "not_supported"
scope_object = "INTERNAL"
queryset = ExternalDataSource.objects.all()
serializer_class = ExternalDataSourceSerializers
filter_backends = [filters.SearchFilter]
Expand Down
2 changes: 1 addition & 1 deletion posthog/warehouse/api/saved_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class DataWarehouseSavedQueryViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewS
Create, Read, Update and Delete Warehouse Tables.
"""

scope_object = "not_supported"
scope_object = "INTERNAL"
queryset = DataWarehouseSavedQuery.objects.all()
serializer_class = DataWarehouseSavedQuerySerializer
filter_backends = [filters.SearchFilter]
Expand Down
2 changes: 1 addition & 1 deletion posthog/warehouse/api/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class TableViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):
Create, Read, Update and Delete Warehouse Tables.
"""

scope_object = "not_supported"
scope_object = "INTERNAL"
queryset = DataWarehouseTable.objects.all()
serializer_class = TableSerializer
filter_backends = [filters.SearchFilter]
Expand Down
2 changes: 1 addition & 1 deletion posthog/warehouse/api/view_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class ViewLinkViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):
Create, Read, Update and Delete View Columns.
"""

scope_object = "not_supported"
scope_object = "INTERNAL"
queryset = DataWarehouseViewLink.objects.all()
serializer_class = ViewLinkSerializer
filter_backends = [filters.SearchFilter]
Expand Down

0 comments on commit 509af94

Please sign in to comment.