(self, request, *args, **kwargs)
| 179 | |
| 180 | @action(detail=True, methods=["GET"], url_path="trait-keys") |
| 181 | def trait_keys(self, request, *args, **kwargs): # type: ignore[no-untyped-def] |
| 182 | keys = [ |
| 183 | trait_key |
| 184 | for trait_key in Trait.objects.filter( |
| 185 | identity__environment=self.get_object() |
| 186 | ) |
| 187 | .order_by() |
| 188 | .values_list("trait_key", flat=True) |
| 189 | .distinct() |
| 190 | ] |
| 191 | |
| 192 | data = {"keys": keys} |
| 193 | |
| 194 | serializer = self.get_serializer(data=data) |
| 195 | if serializer.is_valid(): |
| 196 | return Response(serializer.data, status=status.HTTP_200_OK) |
| 197 | else: |
| 198 | return Response( |
| 199 | {"detail": "Couldn't get trait keys"}, |
| 200 | status=status.HTTP_500_INTERNAL_SERVER_ERROR, |
| 201 | ) |
| 202 | |
| 203 | @action(detail=True, methods=["POST"]) |
| 204 | def clone(self, request, *args, **kwargs): # type: ignore[no-untyped-def] |
nothing calls this directly
no test coverage detected