from __future__ import absolute_import

import six

from rest_framework.response import Response

from sentry.api.bases.project import ProjectEndpoint
from sentry.models import TagKey, TagKeyStatus


class ProjectTagsEndpoint(ProjectEndpoint):
    def get(self, request, project):
        tag_keys = TagKey.objects.filter(
            project=project,
            status=TagKeyStatus.VISIBLE,
        )

        data = []
        for tag_key in tag_keys:
            data.append({
                'id': six.text_type(tag_key.id),
                'key': TagKey.get_standardized_key(tag_key.key),
                'name': tag_key.get_label(),
                'uniqueValues': tag_key.values_seen,
            })

        return Response(data)

[((13, 19, 16, 9), 'sentry.models.TagKey.objects.filter', 'TagKey.objects.filter', (), '', False, 'from sentry.models import TagKey, TagKeyStatus\n'), ((27, 15, 27, 29), 'rest_framework.response.Response', 'Response', ({(27, 24, 27, 28): 'data'}, {}), '(data)', False, 'from rest_framework.response import Response\n'), ((21, 22, 21, 47), 'six.text_type', 'six.text_type', ({(21, 36, 21, 46): 'tag_key.id'}, {}), '(tag_key.id)', False, 'import six\n'), ((22, 23, 22, 63), 'sentry.models.TagKey.get_standardized_key', 'TagKey.get_standardized_key', ({(22, 51, 22, 62): 'tag_key.key'}, {}), '(tag_key.key)', False, 'from sentry.models import TagKey, TagKeyStatus\n')]