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
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
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
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, }
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
def test_consolidate_events(self): assert consolidate_events(["issue.created"]) == {"issue"}
def test_consolidate_events(self): assert consolidate_events(['issue.created']) == set(['issue'])