MCPcopy Index your code
hub / github.com/Flagsmith/flagsmith / trait_keys

Method trait_keys

api/environments/views.py:181–201  ·  view source on GitHub ↗
(self, request, *args, **kwargs)

Source from the content-addressed store, hash-verified

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]

Callers

nothing calls this directly

Calls 2

is_validMethod · 0.80
get_objectMethod · 0.45

Tested by

no test coverage detected