|
@@ -1,4 +1,7 @@
|
|
|
|
+from typing import List
|
|
|
|
+
|
|
from django.db.models import Q
|
|
from django.db.models import Q
|
|
|
|
+from drf_spectacular.utils import OpenApiExample, extend_schema
|
|
from rest_framework.request import Request
|
|
from rest_framework.request import Request
|
|
from rest_framework.response import Response
|
|
from rest_framework.response import Response
|
|
|
|
|
|
@@ -6,24 +9,77 @@ from sentry.api.base import EnvironmentMixin
|
|
from sentry.api.bases.organization import OrganizationEndpoint
|
|
from sentry.api.bases.organization import OrganizationEndpoint
|
|
from sentry.api.paginator import OffsetPaginator
|
|
from sentry.api.paginator import OffsetPaginator
|
|
from sentry.api.serializers import serialize
|
|
from sentry.api.serializers import serialize
|
|
-from sentry.api.serializers.models.project import ProjectSummarySerializer
|
|
|
|
|
|
+from sentry.api.serializers.models.project import (
|
|
|
|
+ OrganizationProjectResponseDict,
|
|
|
|
+ ProjectSummarySerializer,
|
|
|
|
+)
|
|
|
|
+from sentry.apidocs.constants import RESPONSE_FORBIDDEN, RESPONSE_NOTFOUND, RESPONSE_UNAUTHORIZED
|
|
|
|
+from sentry.apidocs.parameters import CURSOR_QUERY_PARAM, GLOBAL_PARAMS
|
|
|
|
+from sentry.apidocs.utils import inline_sentry_response_serializer
|
|
from sentry.models import Project, ProjectStatus, Team
|
|
from sentry.models import Project, ProjectStatus, Team
|
|
from sentry.search.utils import tokenize_query
|
|
from sentry.search.utils import tokenize_query
|
|
|
|
|
|
ERR_INVALID_STATS_PERIOD = "Invalid stats_period. Valid choices are '', '24h', '14d', and '30d'"
|
|
ERR_INVALID_STATS_PERIOD = "Invalid stats_period. Valid choices are '', '24h', '14d', and '30d'"
|
|
|
|
|
|
|
|
|
|
|
|
+@extend_schema(tags=["Organizations"])
|
|
class OrganizationProjectsEndpoint(OrganizationEndpoint, EnvironmentMixin):
|
|
class OrganizationProjectsEndpoint(OrganizationEndpoint, EnvironmentMixin):
|
|
|
|
+ public = {"GET"}
|
|
|
|
+
|
|
|
|
+ @extend_schema(
|
|
|
|
+ operation_id="List an Organization's Projects",
|
|
|
|
+ parameters=[GLOBAL_PARAMS.ORG_SLUG, CURSOR_QUERY_PARAM],
|
|
|
|
+ request=None,
|
|
|
|
+ responses={
|
|
|
|
+ 200: inline_sentry_response_serializer(
|
|
|
|
+ "OrganizationProjectResponseDict", List[OrganizationProjectResponseDict]
|
|
|
|
+ ),
|
|
|
|
+ 401: RESPONSE_UNAUTHORIZED,
|
|
|
|
+ 403: RESPONSE_FORBIDDEN,
|
|
|
|
+ 404: RESPONSE_NOTFOUND,
|
|
|
|
+ },
|
|
|
|
+ examples=[
|
|
|
|
+ OpenApiExample(
|
|
|
|
+ "Success",
|
|
|
|
+ value=[
|
|
|
|
+ {
|
|
|
|
+ "dateCreated": "2018-11-06T21:19:58.536Z",
|
|
|
|
+ "firstEvent": None,
|
|
|
|
+ "hasAccess": True,
|
|
|
|
+ "id": "3",
|
|
|
|
+ "isBookmarked": False,
|
|
|
|
+ "isMember": True,
|
|
|
|
+ "name": "Prime Mover",
|
|
|
|
+ "platform": "",
|
|
|
|
+ "platforms": [],
|
|
|
|
+ "slug": "prime-mover",
|
|
|
|
+ "team": {
|
|
|
|
+ "id": "2",
|
|
|
|
+ "name": "Powerful Abolitionist",
|
|
|
|
+ "slug": "powerful-abolitionist",
|
|
|
|
+ },
|
|
|
|
+ "teams": [
|
|
|
|
+ {
|
|
|
|
+ "id": "2",
|
|
|
|
+ "name": "Powerful Abolitionist",
|
|
|
|
+ "slug": "powerful-abolitionist",
|
|
|
|
+ }
|
|
|
|
+ ],
|
|
|
|
+ "environments": ["local"],
|
|
|
|
+ "eventProcessing": {"symbolicationDegraded": False},
|
|
|
|
+ "features": ["releases"],
|
|
|
|
+ "firstTransactionEvent": True,
|
|
|
|
+ "hasSessions": True,
|
|
|
|
+ "latestRelease": None,
|
|
|
|
+ "hasUserReports": False,
|
|
|
|
+ }
|
|
|
|
+ ],
|
|
|
|
+ )
|
|
|
|
+ ],
|
|
|
|
+ )
|
|
def get(self, request: Request, organization) -> Response:
|
|
def get(self, request: Request, organization) -> Response:
|
|
"""
|
|
"""
|
|
- List an Organization's Projects
|
|
|
|
- ```````````````````````````````
|
|
|
|
-
|
|
|
|
Return a list of projects bound to a organization.
|
|
Return a list of projects bound to a organization.
|
|
-
|
|
|
|
- :pparam string organization_slug: the slug of the organization for
|
|
|
|
- which the projects should be listed.
|
|
|
|
- :auth: required
|
|
|
|
"""
|
|
"""
|
|
stats_period = request.GET.get("statsPeriod")
|
|
stats_period = request.GET.get("statsPeriod")
|
|
collapse = request.GET.getlist("collapse", [])
|
|
collapse = request.GET.getlist("collapse", [])
|