Example #1
0
    def serialize(self, obj, attrs, user):
        from sentry.api.endpoints.project_releases_token import _get_webhook_url
        doc = ''

        if self.project is not None:
            release_token = ProjectOption.objects.get_value(self.project, 'sentry:release-token')
            if release_token is not None:
                webhook_url = _get_webhook_url(self.project, obj.slug, release_token)

                if hasattr(obj, 'get_release_doc_html'):
                    try:
                        doc = obj.get_release_doc_html(webhook_url)
                    except NotImplementedError:
                        pass

        contexts = []
        if hasattr(obj, 'get_custom_contexts'):
            contexts.extend(x.type for x in obj.get_custom_contexts() or ())
        d = {
            'id': obj.slug,
            'name': six.text_type(obj.get_title()),
            'slug': obj.slug or slugify(six.text_type(obj.get_title())),
            'shortName': six.text_type(obj.get_short_title()),
            'type': obj.get_plugin_type(),
            'canDisable': obj.can_disable,
            'isTestable': hasattr(obj, 'is_testable') and obj.is_testable(),
            'hasConfiguration': obj.has_project_conf(),
            'metadata': obj.get_metadata(),
            'contexts': contexts,
            'status': obj.get_status(),
            'assets': [
                {
                    'url': absolute_uri(get_asset_url(obj.asset_key or obj.slug, asset)),
                } for asset in obj.get_assets()
            ],
            'doc': doc,
        }
        if self.project:
            d['enabled'] = obj.is_enabled(self.project)

        if obj.version:
            d['version'] = six.text_type(obj.version)

        if obj.author:
            d['author'] = {
                'name': six.text_type(obj.author),
                'url': six.text_type(obj.author_url)
            }

        d['isHidden'] = d.get('enabled', False) is False and obj.is_hidden()

        if obj.description:
            d['description'] = six.text_type(obj.description)

        if obj.resource_links:
            d['resourceLinks'] = [
                {'title': title, 'url': url} for [title, url] in obj.resource_links
            ]

        return d
Example #2
0
    def serialize(self, obj, attrs, user):
        from sentry.api.endpoints.project_releases_token import _get_webhook_url

        doc = ""

        if self.project is not None:
            release_token = ProjectOption.objects.get_value(self.project, "sentry:release-token")
            if release_token is not None:
                webhook_url = _get_webhook_url(self.project, obj.slug, release_token)

                if hasattr(obj, "get_release_doc_html"):
                    try:
                        doc = obj.get_release_doc_html(webhook_url)
                    except NotImplementedError:
                        pass

        contexts = []
        if hasattr(obj, "get_custom_contexts"):
            contexts.extend(x.type for x in obj.get_custom_contexts() or ())
        d = {
            "id": obj.slug,
            "name": six.text_type(obj.get_title()),
            "slug": obj.slug or slugify(six.text_type(obj.get_title())),
            "shortName": six.text_type(obj.get_short_title()),
            "type": obj.get_plugin_type(),
            "canDisable": obj.can_disable,
            "isTestable": hasattr(obj, "is_testable") and obj.is_testable(),
            "hasConfiguration": obj.has_project_conf(),
            "metadata": obj.get_metadata(),
            "contexts": contexts,
            "status": obj.get_status(),
            "assets": [
                {"url": absolute_uri(get_asset_url(obj.asset_key or obj.slug, asset))}
                for asset in obj.get_assets()
            ],
            "doc": doc,
        }
        if self.project:
            d["enabled"] = obj.is_enabled(self.project)

        if obj.version:
            d["version"] = six.text_type(obj.version)

        if obj.author:
            d["author"] = {"name": six.text_type(obj.author), "url": six.text_type(obj.author_url)}

        d["isHidden"] = d.get("enabled", False) is False and obj.is_hidden()

        if obj.description:
            d["description"] = six.text_type(obj.description)

        if obj.resource_links:
            d["resourceLinks"] = [
                {"title": title, "url": url} for [title, url] in obj.resource_links
            ]

        return d
Example #3
0
    def serialize(self, obj, attrs, user):
        from sentry.api.endpoints.project_releases_token import _get_webhook_url
        doc = ''

        release_token = ProjectOption.objects.get_value(
            self.project, 'sentry:release-token')
        if release_token is not None:
            webhook_url = _get_webhook_url(self.project, obj.slug,
                                           release_token)

            if hasattr(obj, 'get_release_doc_html'):
                try:
                    doc = obj.get_release_doc_html(webhook_url)
                except NotImplementedError:
                    pass

        contexts = []
        if hasattr(obj, 'get_custom_contexts'):
            contexts.extend(x.type for x in obj.get_custom_contexts() or ())
        d = {
            'id':
            obj.slug,
            'name':
            six.text_type(obj.get_title()),
            'type':
            obj.get_plugin_type(),
            'canDisable':
            obj.can_disable,
            'isTestable':
            hasattr(obj, 'is_testable') and obj.is_testable(),
            'metadata':
            obj.get_metadata(),
            'contexts':
            contexts,
            'status':
            obj.get_status(),
            'assets': [{
                'url':
                absolute_uri(get_asset_url(obj.asset_key or obj.slug, asset)),
            } for asset in obj.get_assets()],
            'doc':
            doc,
        }
        if self.project:
            d['enabled'] = obj.is_enabled(self.project)
        return d
Example #4
0
    def serialize(self, obj, attrs, user):
        from sentry.api.endpoints.project_releases_token import _get_webhook_url
        doc = ''

        release_token = ProjectOption.objects.get_value(self.project, 'sentry:release-token')
        if release_token is not None:
            webhook_url = _get_webhook_url(self.project, obj.slug, release_token)

            if hasattr(obj, 'get_release_doc_html'):
                try:
                    doc = obj.get_release_doc_html(webhook_url)
                except NotImplementedError:
                    pass

        contexts = []
        if hasattr(obj, 'get_custom_contexts'):
            contexts.extend(x.type for x in obj.get_custom_contexts() or ())
        d = {
            'id': obj.slug,
            'name': six.text_type(obj.get_title()),
            'shortName': six.text_type(obj.get_short_title()),
            'type': obj.get_plugin_type(),
            'canDisable': obj.can_disable,
            'isTestable': hasattr(obj, 'is_testable') and obj.is_testable(),
            'metadata': obj.get_metadata(),
            'contexts': contexts,
            'status': obj.get_status(),
            'assets': [
                {
                    'url': absolute_uri(get_asset_url(obj.asset_key or obj.slug, asset)),
                } for asset in obj.get_assets()
            ],
            'doc': doc,
        }
        if self.project:
            d['enabled'] = obj.is_enabled(self.project)
        return d
Example #5
0
    def serialize(self, obj, attrs, user):
        from sentry.api.endpoints.project_releases_token import _get_webhook_url
        doc = ''

        release_token = ProjectOption.objects.get_value(
            self.project, 'sentry:release-token')
        if release_token is not None:
            webhook_url = _get_webhook_url(self.project, obj.slug,
                                           release_token)

            if hasattr(obj, 'get_release_doc_html'):
                try:
                    doc = obj.get_release_doc_html(webhook_url)
                except NotImplementedError:
                    pass

        contexts = []
        if hasattr(obj, 'get_custom_contexts'):
            contexts.extend(x.type for x in obj.get_custom_contexts() or ())
        d = {
            'id':
            obj.slug,
            'name':
            six.text_type(obj.get_title()),
            'slug':
            obj.slug or slugify(six.text_type(obj.get_title())),
            'shortName':
            six.text_type(obj.get_short_title()),
            'type':
            obj.get_plugin_type(),
            'canDisable':
            obj.can_disable,
            'isTestable':
            hasattr(obj, 'is_testable') and obj.is_testable(),
            'hasConfiguration':
            obj.has_project_conf(),
            'metadata':
            obj.get_metadata(),
            'contexts':
            contexts,
            'status':
            obj.get_status(),
            'assets': [{
                'url':
                absolute_uri(get_asset_url(obj.asset_key or obj.slug, asset)),
            } for asset in obj.get_assets()],
            'doc':
            doc,
        }
        if self.project:
            d['enabled'] = obj.is_enabled(self.project)

        if obj.version:
            d['version'] = six.text_type(obj.version)

        if obj.author:
            d['author'] = {
                'name': six.text_type(obj.author),
                'url': six.text_type(obj.author_url)
            }

        if obj.description:
            d['description'] = six.text_type(obj.description)

        if obj.resource_links:
            d['resourceLinks'] = [{
                'title': title,
                'url': url
            } for [title, url] in obj.resource_links]

        return d
Example #6
0
    def serialize(self, obj, attrs, user):
        from sentry.api.endpoints.project_releases_token import _get_webhook_url

        doc = ""

        if self.project is not None:
            release_token = ProjectOption.objects.get_value(
                self.project, "sentry:release-token")
            if release_token is not None:
                webhook_url = _get_webhook_url(self.project, obj.slug,
                                               release_token)

                if hasattr(obj, "get_release_doc_html"):
                    try:
                        doc = obj.get_release_doc_html(webhook_url)
                    except NotImplementedError:
                        pass

        contexts = []
        if hasattr(obj, "get_custom_contexts"):
            contexts.extend(x.type for x in obj.get_custom_contexts() or ())

        deprecation_date = getattr(obj, "deprecation_date", None)

        d = {
            "id":
            obj.slug,
            "name":
            str(obj.get_title()),
            "slug":
            obj.slug or slugify(str(obj.get_title())),
            "shortName":
            str(obj.get_short_title()),
            "type":
            obj.get_plugin_type(),
            "canDisable":
            obj.can_disable,
            "isTestable":
            hasattr(obj, "is_testable") and obj.is_testable(),
            "hasConfiguration":
            obj.has_project_conf(),
            "metadata":
            obj.get_metadata(),
            "contexts":
            contexts,
            "status":
            obj.get_status(),
            "assets": [{
                "url":
                absolute_uri(get_asset_url(obj.asset_key or obj.slug, asset))
            } for asset in obj.get_assets()],
            "doc":
            doc,
            "firstPartyAlternative":
            getattr(obj, "alternative", None),
            "deprecationDate":
            deprecation_date.strftime("%b %-d, %Y")
            if deprecation_date else None,
            "altIsSentryApp":
            getattr(obj, "alt_is_sentry_app", None),
        }
        if self.project:
            d["enabled"] = obj.is_enabled(self.project)

        if obj.version:
            d["version"] = str(obj.version)

        if obj.author:
            d["author"] = {"name": str(obj.author), "url": str(obj.author_url)}

        d["isDeprecated"] = is_plugin_deprecated(obj, self.project)

        d["isHidden"] = d["isDeprecated"] or (not d.get("enabled", False)
                                              and obj.is_hidden())

        if obj.description:
            d["description"] = str(obj.description)

        d["features"] = list(
            {f.featureGate.value
             for f in obj.feature_descriptions})

        d["featureDescriptions"] = [{
            "description":
            f.description.strip(),
            "featureGate":
            obj.feature_flag_name(f.featureGate.value),
        } for f in obj.feature_descriptions]

        if obj.resource_links:
            d["resourceLinks"] = [{
                "title": title,
                "url": url
            } for [title, url] in obj.resource_links]

        return d