コード例 #1
0
    def serialize(self, obj, attrs, user):
        from sentry.mediators.service_hooks.creator import consolidate_events

        data = {
            'name': obj.name,
            'slug': obj.slug,
            'author': obj.author,
            'scopes': obj.get_scopes(),
            'events': consolidate_events(obj.events),
            'status': obj.get_status_display(),
            'schema': obj.schema,
            'uuid': obj.uuid,
            'webhookUrl': obj.webhook_url,
            'redirectUrl': obj.redirect_url,
            'isAlertable': obj.is_alertable,
            'overview': obj.overview,
        }

        if is_active_superuser(
                env.request) or (hasattr(user, 'get_orgs')
                                 and obj.owner in user.get_orgs()):
            data.update({
                'clientId': obj.application.client_id,
                'clientSecret': obj.application.client_secret,
            })

        return data
コード例 #2
0
    def serialize(self, obj, attrs, user, access):
        from sentry.mediators.service_hooks.creator import consolidate_events

        data = {
            "name": obj.name,
            "slug": obj.slug,
            "author": obj.author,
            "scopes": obj.get_scopes(),
            "events": consolidate_events(obj.events),
            "status": obj.get_status_display(),
            "schema": obj.schema,
            "uuid": obj.uuid,
            "webhookUrl": obj.webhook_url,
            "redirectUrl": obj.redirect_url,
            "isAlertable": obj.is_alertable,
            "verifyInstall": obj.verify_install,
            "overview": obj.overview,
            "allowedOrigins": obj.application.get_allowed_origins(),
        }

        if is_active_superuser(env.request) or (
            hasattr(user, "get_orgs") and obj.owner in user.get_orgs()
        ):
            client_secret = (
                obj.application.client_secret if obj.show_auth_info(access) else MASKED_VALUE
            )
            data.update(
                {
                    "clientId": obj.application.client_id,
                    "clientSecret": client_secret,
                    "owner": {"id": obj.owner.id, "slug": obj.owner.slug},
                }
            )

        return data
コード例 #3
0
ファイル: sentry_app.py プロジェクト: getsentry/sentry
    def serialize(self, obj, attrs, user):
        from sentry.mediators.service_hooks.creator import consolidate_events

        data = {
            'name': obj.name,
            'slug': obj.slug,
            'author': obj.author,
            'scopes': obj.get_scopes(),
            'events': consolidate_events(obj.events),
            'status': obj.get_status_display(),
            'schema': obj.schema,
            'uuid': obj.uuid,
            'webhookUrl': obj.webhook_url,
            'redirectUrl': obj.redirect_url,
            'isAlertable': obj.is_alertable,
            'overview': obj.overview,
        }

        if is_active_superuser(env.request) or (
            hasattr(user, 'get_orgs') and obj.owner in user.get_orgs()
        ):
            data.update({
                'clientId': obj.application.client_id,
                'clientSecret': obj.application.client_secret,
                'owner': {
                    'id': obj.owner.id,
                    'slug': obj.owner.slug,
                },
            })

        return data
コード例 #4
0
ファイル: sentry_app.py プロジェクト: commonlims/commonlims
 def serialize(self, obj, attrs, user):
     from sentry.mediators.service_hooks.creator import consolidate_events
     return {
         'name': obj.name,
         'slug': obj.slug,
         'scopes': obj.get_scopes(),
         'events': consolidate_events(obj.events),
         'status': obj.get_status_display(),
         'uuid': obj.uuid,
         'webhookUrl': obj.webhook_url,
         'redirectUrl': obj.redirect_url,
         'isAlertable': obj.is_alertable,
         'clientId': obj.application.client_id,
         'clientSecret': obj.application.client_secret,
         'overview': obj.overview,
     }
コード例 #5
0
ファイル: sentry_app.py プロジェクト: wangjianweiwei/sentry
    def serialize(self, obj, attrs, user, access):
        from sentry.mediators.service_hooks.creator import consolidate_events

        data = {
            "name": obj.name,
            "slug": obj.slug,
            "author": obj.author,
            "scopes": obj.get_scopes(),
            "events": consolidate_events(obj.events),
            "status": obj.get_status_display(),
            "schema": obj.schema,
            "uuid": obj.uuid,
            "webhookUrl": obj.webhook_url,
            "redirectUrl": obj.redirect_url,
            "isAlertable": obj.is_alertable,
            "verifyInstall": obj.verify_install,
            "overview": obj.overview,
            "allowedOrigins": obj.application.get_allowed_origins(),
            "popularity": obj.popularity,
        }

        data["featureData"] = []

        if obj.status != SentryAppStatus.INTERNAL:
            data["featureData"] = map(lambda x: serialize(x, user), attrs.get("features"))

        if obj.status == SentryAppStatus.PUBLISHED and obj.date_published:
            data.update({"datePublished": obj.date_published})

        if (env.request and is_active_superuser(env.request)) or (
            hasattr(user, "get_orgs") and obj.owner in user.get_orgs()
        ):
            client_secret = (
                obj.application.client_secret if obj.show_auth_info(access) else MASKED_VALUE
            )
            data.update(
                {
                    "clientId": obj.application.client_id,
                    "clientSecret": client_secret,
                    "owner": {"id": obj.owner.id, "slug": obj.owner.slug},
                }
            )

        data.update({"avatars": serialize(attrs.get("avatars"), user)})

        return data
コード例 #6
0
 def test_consolidate_events(self):
     assert consolidate_events(["issue.created"]) == {"issue"}
コード例 #7
0
ファイル: test_creator.py プロジェクト: Kayle009/sentry
 def test_consolidate_events(self):
     assert consolidate_events(['issue.created']) == set(['issue'])
コード例 #8
0
 def test_consolidate_events(self):
     assert consolidate_events(['issue.created']) == set(['issue'])