remove grafana_plugin_management django app (#812)

* remove grafana_plugin_management django app

it seems to be no longer used or referenced. In addition apps.api.serializers.organization.PluginOrganizationSerializer was only
referenced from within grafana_plugin_management and is thereby safe
to remove.
This commit is contained in:
Joey Orlando 2022-11-09 13:53:59 +01:00 committed by GitHub
parent a27a55b36d
commit fd4877408a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 1 additions and 99 deletions

View file

@ -3,6 +3,7 @@
## v1.0.52 (TBD)
- Allow use of API keys as alternative to account auth token for Twilio
- Remove `grafana_plugin_management` Django app
## v1.0.51 (2022-11-05)

View file

@ -162,22 +162,3 @@ class FastOrganizationSerializer(serializers.ModelSerializer):
class Meta:
model = Organization
fields = ["pk", "name"]
class PluginOrganizationSerializer(serializers.ModelSerializer):
pk = serializers.CharField(read_only=True, source="public_primary_key")
grafana_token = serializers.CharField(write_only=True, source="api_token")
class Meta:
model = Organization
fields = [
"pk",
"stack_id",
"stack_slug",
"grafana_url",
"org_id",
"org_slug",
"org_title",
"region_slug",
"grafana_token",
]

View file

@ -1,13 +0,0 @@
from django.urls import include, path
from apps.grafana_plugin_management.views import PluginInstallationsView
from common.api_helpers.optional_slash_router import OptionalSlashRouter
app_name = "grafana-plugin-management"
router = OptionalSlashRouter()
router.register(r"plugin_installations", PluginInstallationsView, basename="plugin_installations")
urlpatterns = [
path("", include(router.urls)),
]

View file

@ -1 +0,0 @@
from .plugin_installations import PluginInstallationsView # noqa: F401

View file

@ -1,64 +0,0 @@
from rest_framework import status
from rest_framework.authentication import BasicAuthentication, SessionAuthentication
from rest_framework.decorators import action
from rest_framework.mixins import CreateModelMixin, ListModelMixin, RetrieveModelMixin
from rest_framework.response import Response
from rest_framework.viewsets import GenericViewSet
from apps.api.permissions import IsStaff
from apps.api.serializers.organization import PluginOrganizationSerializer
from apps.grafana_plugin.helpers.client import GrafanaAPIClient
from apps.user_management.models import Organization
from apps.user_management.sync import sync_organization
from common.api_helpers.mixins import PublicPrimaryKeyMixin
class PluginInstallationsView(
PublicPrimaryKeyMixin,
CreateModelMixin,
RetrieveModelMixin,
ListModelMixin,
GenericViewSet,
):
authentication_classes = [BasicAuthentication, SessionAuthentication]
permission_classes = (IsStaff,)
model = Organization
serializer_class = PluginOrganizationSerializer
def get_queryset(self):
return Organization.objects.all()
def create(self, request, *args, **kwargs):
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
organization = serializer.save()
sync_organization(organization)
return Response(data=organization.provision_plugin(), status=status.HTTP_201_CREATED)
@action(methods=["post"], detail=True)
def revoke_and_reissue(self, request, pk):
organization = self.get_object()
serializer = self.get_serializer(organization, data=request.data)
serializer.is_valid(raise_exception=True)
serializer.save()
return Response(data=organization.provision_plugin())
@action(methods=["post"], detail=True)
def revoke(self, request, pk):
organization = self.get_object()
organization.revoke_plugin()
return Response(data={"details": "Plugin token revoked"})
@action(methods=["get"], detail=True)
def status(self, request, pk):
organization = self.get_object()
client = GrafanaAPIClient(api_url=organization.grafana_url, api_token=organization.api_token)
_, grafana_status = client.check_token()
return Response(data=grafana_status)
@action(methods=["post"], detail=True)
def sync_organization(self, request, pk):
organization = self.get_object()
sync_organization(organization)
return Response(data={"details": "Sync organization complete"})

View file

@ -32,7 +32,6 @@ urlpatterns = [
path("api/internal/v1/", include("apps.api.urls", namespace="api-internal")),
path("api/internal/v1/", include("social_django.urls", namespace="social")),
path("api/internal/v1/plugin/", include("apps.grafana_plugin.urls", namespace="grafana-plugin")),
path("api/internal/v1/", include("apps.grafana_plugin_management.urls", namespace="grafana-plugin-management")),
path("api/internal/v1/", include("apps.social_auth.urls", namespace="social_auth")),
path("integrations/v1/", include("apps.integrations.urls", namespace="integrations")),
path("twilioapp/", include("apps.twilioapp.urls")),

View file

@ -208,7 +208,6 @@ INSTALLED_APPS = [
"apps.auth_token",
"apps.public_api",
"apps.grafana_plugin",
"apps.grafana_plugin_management",
"corsheaders",
"debug_toolbar",
"social_django",