From 9a6dc4d0eff92df6e95a4d78fd3fc46f2153e997 Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Tue, 9 May 2017 15:01:04 -0400 Subject: [PATCH] add a view for `/api/v2/credential_types/N/activity_stream/` --- awx/api/serializers.py | 9 ++++++--- awx/api/urls.py | 1 + awx/api/views.py | 10 ++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/awx/api/serializers.py b/awx/api/serializers.py index d28545af6e..6aea867e73 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -1869,10 +1869,13 @@ class CredentialTypeSerializer(BaseSerializer): def get_related(self, obj): res = super(CredentialTypeSerializer, self).get_related(obj) - res['credentials'] = reverse( + res['credentials'] = self.reverse( 'api:credential_type_credential_list', - kwargs={'pk': obj.pk}, - request=self.context.get('request') + kwargs={'pk': obj.pk} + ) + res['activity_stream'] = self.reverse( + 'api:credential_type_activity_stream_list', + kwargs={'pk': obj.pk} ) return res diff --git a/awx/api/urls.py b/awx/api/urls.py index b065563e92..95241638c8 100644 --- a/awx/api/urls.py +++ b/awx/api/urls.py @@ -167,6 +167,7 @@ credential_type_urls = patterns('awx.api.views', url(r'^$', 'credential_type_list'), url(r'^(?P[0-9]+)/$', 'credential_type_detail'), url(r'^(?P[0-9]+)/credentials/$', 'credential_type_credential_list'), + url(r'^(?P[0-9]+)/activity_stream/$', 'credential_type_activity_stream_list'), ) credential_urls = patterns('awx.api.views', diff --git a/awx/api/views.py b/awx/api/views.py index 8160400ec4..9c41db0e86 100644 --- a/awx/api/views.py +++ b/awx/api/views.py @@ -1521,6 +1521,16 @@ class CredentialTypeCredentialList(SubListAPIView): new_in_api_v2 = True +class CredentialTypeActivityStreamList(ActivityStreamEnforcementMixin, SubListAPIView): + + model = ActivityStream + serializer_class = ActivityStreamSerializer + parent_model = CredentialType + relationship = 'activitystream_set' + new_in_320 = True + new_in_api_v2 = True + + class CredentialList(ListCreateAPIView): model = Credential