Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/sentry/api/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ class Endpoint(APIView):

cursor_name = "cursor"

# end user of endpoint must set private to true, or define public endpoints
private: Optional[bool] = None
public: Optional[HTTP_METHODS_SET] = None

rate_limits: RateLimitConfig = DEFAULT_RATE_LIMIT_CONFIG
Expand Down
1 change: 0 additions & 1 deletion src/sentry/api/endpoints/admin_project_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

@pending_silo_endpoint
class AdminRelayProjectConfigsEndpoint(Endpoint):
private = True
permission_classes = (SuperuserPermission,)

def get(self, request: Request) -> Response:
Expand Down
4 changes: 0 additions & 4 deletions src/sentry/api/endpoints/client_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

@pending_silo_endpoint
class ClientStateListEndpoint(OrganizationEndpoint):
private = True

def __init__(self, **options) -> None:
cluster_key = getattr(settings, "SENTRY_CLIENT_STATE_REDIS_CLUSTER", "default")
self.client = redis.redis_clusters.get(cluster_key)
Expand All @@ -33,8 +31,6 @@ def get(self, request: Request, organization) -> Response:

@pending_silo_endpoint
class ClientStateEndpoint(OrganizationEndpoint):
private = True

def __init__(self, **options) -> None:
self.client = get_redis_client()
super().__init__(**options)
Expand Down
1 change: 0 additions & 1 deletion src/sentry/api/endpoints/issue_occurrence.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
@region_silo_endpoint
class IssueOccurrenceEndpoint(Endpoint):
permission_classes = (SuperuserPermission,)
private = True

def post(self, request: Request) -> Response:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ def validate_span(self, span: str) -> Span:

@region_silo_endpoint
class OrganizationEventsSpansHistogramEndpoint(OrganizationEventsV2EndpointBase):
private = True

def has_feature(self, organization, request):
return features.has(
"organizations:performance-span-histogram-view", organization, actor=request.user
Expand Down
2 changes: 0 additions & 2 deletions src/sentry/api/endpoints/organization_integration_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

@region_silo_endpoint
class OrganizationIntegrationIssuesEndpoint(OrganizationIntegrationBaseEndpoint):
private = True

def put(self, request: Request, organization, integration_id) -> Response:
"""
Migrate plugin linked issues to integration linked issues
Expand Down
2 changes: 0 additions & 2 deletions src/sentry/api/endpoints/organization_measurements_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

@region_silo_endpoint
class OrganizationMeasurementsMeta(OrganizationEventsEndpointBase): # type: ignore
private = True

def get(self, request: Request, organization: Organization) -> Response:
try:
params = self.get_snuba_params(request, organization)
Expand Down
4 changes: 0 additions & 4 deletions src/sentry/api/endpoints/organization_metrics_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ class OrganizationMetricsCompatibility(OrganizationEventsEndpointBase):
which are the projects which don't have null transactions and have at least 1 transaction with a valid name
"""

private = True

def get(self, request: Request, organization) -> Response:
data = {
"incompatible_projects": [],
Expand Down Expand Up @@ -68,8 +66,6 @@ class OrganizationMetricsCompatibilitySums(OrganizationEventsEndpointBase):
be
"""

private = True

def get(self, request: Request, organization) -> Response:
data = {
"sum": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def get_request_builder_args(user: User, organization: Organization, platforms:

@region_silo_endpoint
class OrganizationOnboardingContinuationEmail(OrganizationEndpoint):
private = True

# let anyone in the org use this endpoint
permission_classes = ()

Expand Down
2 changes: 0 additions & 2 deletions src/sentry/api/endpoints/organization_profiling_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@


class OrganizationProfilingBaseEndpoint(OrganizationEventsV2EndpointBase): # type: ignore
private = True

def get_profiling_params(self, request: Request, organization: Organization) -> Dict[str, Any]:
try:
params: Dict[str, Any] = parse_profile_filters(request.query_params.get("query", ""))
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/organization_sentry_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def validate_env_variables(self, env_variables):

@region_silo_endpoint
class OrganizationSentryFunctionEndpoint(OrganizationEndpoint):
private = True

# Creating a new sentry function

def post(self, request, organization):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

@region_silo_endpoint
class OrganizationSentryFunctionDetailsEndpoint(OrganizationEndpoint):
private = True

def convert_args(self, request, organization_slug, function_slug, *args, **kwargs):
args, kwargs = super().convert_args(request, organization_slug, *args, **kwargs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ class AppStoreConnectRefreshEndpoint(ProjectEndpoint): # type: ignore
"""

permission_classes = [StrictProjectPermission]
private = True

enforce_rate_limit = True

# At the time of writing the App Store Connect API has a rate limit of 3600 requests/h
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/project_commits.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@region_silo_endpoint
class ProjectCommitsEndpoint(ProjectEndpoint):
private = True

permission_classes = (ProjectReleasePermission,)

def get(self, request: Request, project) -> Response:
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/project_dynamic_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class DynamicSamplingPermission(ProjectPermission):

@region_silo_endpoint
class ProjectDynamicSamplingDistributionEndpoint(ProjectEndpoint):
private = True

permission_classes = (DynamicSamplingPermission,)

@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ProjectPerformanceIssueSettingsSerializer(serializers.Serializer):

@region_silo_endpoint
class ProjectPerformanceIssueSettingsEndpoint(ProjectEndpoint):
private = True # TODO: Remove after EA.
# TODO: Remove after EA.
permission_classes = (ProjectSettingPermission,)

def has_feature(self, project, request) -> bool:
Expand Down
2 changes: 0 additions & 2 deletions src/sentry/api/endpoints/project_profiling_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@


class ProjectProfilingBaseEndpoint(ProjectEndpoint): # type: ignore
private = True

def get_profiling_params(self, request: Request, project: Project) -> Dict[str, Any]:
try:
params: Dict[str, Any] = parse_profile_filters(request.query_params.get("query", ""))
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/project_rule_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

@region_silo_endpoint
class ProjectRuleActionsEndpoint(ProjectEndpoint):
private = True

permission_classes = (ProjectAlertRulePermission,)

@transaction_start("ProjectRuleActionsEndpoint")
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/project_rule_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

@region_silo_endpoint
class ProjectRulePreviewEndpoint(ProjectEndpoint):
private = True

permission_classes = (ProjectAlertRulePermission,)

# a post endpoint because it's too hard to pass a list of objects from the frontend
Expand Down
2 changes: 0 additions & 2 deletions src/sentry/api/endpoints/project_transaction_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

@region_silo_endpoint
class ProjectTransactionNamesCluster(ProjectEndpoint):
private = True

def get(self, request: Request, project) -> Response:
"""Run the transaction name clusterer and return its output.

Expand Down
33 changes: 2 additions & 31 deletions src/sentry/apidocs/hooks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from typing import Any, Dict, Literal, Mapping, Set, TypedDict

from drf_spectacular.drainage import warn

from sentry.apidocs.build import OPENAPI_TAGS
from sentry.apidocs.utils import SentryApiBuildError

Expand All @@ -26,22 +24,9 @@ class EndpointRegistryType(TypedDict):


def custom_preprocessing_hook(endpoints: Any) -> Any: # TODO: organize method, rename
from sentry.apidocs.public_exclusion_list import (
EXCLUDED_FROM_PUBLIC_ENDPOINTS,
PUBLIC_ENDPOINTS_FROM_JSON,
)

registered_endpoints = PUBLIC_ENDPOINTS_FROM_JSON | EXCLUDED_FROM_PUBLIC_ENDPOINTS

filtered = []
for (path, path_regex, method, callback) in endpoints:
view = f"{callback.__module__}.{callback.__name__}"

if callback.view_class.public and callback.view_class.private:
warn( # type: ignore[no-untyped-call]
"both `public` and `private` cannot be defined at the same time, "
"please remove one of the attributes."
)

if any(path.startswith(p) for p in EXCLUSION_PATH_PREFIXES):
pass
Expand All @@ -53,23 +38,9 @@ def custom_preprocessing_hook(endpoints: Any) -> Any: # TODO: organize method,
# to the rest of the OpenAPI build pipeline
filtered.append((path, path_regex, method, callback))

elif view in registered_endpoints:
# don't error if endpoint is added to exclusion list
pass

elif callback.view_class.private:
# if the endpoint is explicitly private, that's okay.
pass
else:
# any new endpoint that isn't accounted for should recieve this error when building api docs
warn( # type: ignore[no-untyped-call]
f"{view} {method} is unaccounted for. "
"Either document the endpoint and define the `public` attribute on the endpoint "
"with the public HTTP methods, "
"or set the `private` attribute on the endpoint to `True`. "
"See https://develop.sentry.dev/api/public/ for more info on "
"making APIs public."
)
# if an endpoint doesn't have any registered public methods, don't check it.
pass

return filtered

Expand Down
Loading