def get(self, request, group, integration_id): # Keep link/create separate since create will likely require # many external API calls that aren't necessary if the user is # just linking action = request.GET.get('action') if action not in {'link', 'create'}: return Response({'detail': 'Action is required and should be either link or create'}) organization_id = group.project.organization_id try: integration = Integration.objects.get( id=integration_id, organizations=organization_id, ) except Integration.DoesNotExist: return Response(status=404) if not (integration.has_feature(IntegrationFeatures.ISSUE_BASIC) or integration.has_feature( IntegrationFeatures.ISSUE_SYNC)): return Response( {'detail': 'This feature is not supported for this integration.'}, status=400) # TODO(jess): add create issue config to serializer return Response( serialize( integration, request.user, IntegrationIssueConfigSerializer(group, action, params=request.GET), organization_id=organization_id ) )
def get(self, request: Request, group, integration_id) -> Response: if not self._has_issue_feature(group.organization, request.user): return Response({"detail": MISSING_FEATURE_MESSAGE}, status=400) # Keep link/create separate since create will likely require # many external API calls that aren't necessary if the user is # just linking action = request.GET.get("action") if action not in {"link", "create"}: return Response({ "detail": "Action is required and should be either link or create" }) organization_id = group.project.organization_id try: integration = Integration.objects.get( id=integration_id, organizations=organization_id) except Integration.DoesNotExist: return Response(status=404) if not (integration.has_feature(IntegrationFeatures.ISSUE_BASIC) or integration.has_feature(IntegrationFeatures.ISSUE_SYNC)): return Response( { "detail": "This feature is not supported for this integration." }, status=400) try: return Response( serialize( integration, request.user, IntegrationIssueConfigSerializer(group, action, params=request.GET), organization_id=organization_id, )) except IntegrationError as e: return Response({"detail": str(e)}, status=400)