Skip to content

Commit

Permalink
Add a sublist api view for the UJTs that use a given execution enviro…
Browse files Browse the repository at this point in the history
…nment
  • Loading branch information
jbradberry authored and AlanCoding committed Sep 10, 2020
1 parent 6ec9263 commit d70c4f6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion awx/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,8 @@ class Meta:
def get_related(self, obj):
res = super(ExecutionEnvironmentSerializer, self).get_related(obj)
res.update(
activity_stream = self.reverse('api:execution_environment_activity_stream_list', kwargs={'pk': obj.pk}),
activity_stream=self.reverse('api:execution_environment_activity_stream_list', kwargs={'pk': obj.pk}),
unified_job_templates=self.reverse('api:execution_environment_job_template_list', kwargs={'pk': obj.pk}),
)
if obj.organization:
res['organization'] = self.reverse('api:organization_detail', kwargs={'pk': obj.organization.pk})
Expand Down
2 changes: 2 additions & 0 deletions awx/api/urls/execution_environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
from awx.api.views import (
ExecutionEnvironmentList,
ExecutionEnvironmentDetail,
ExecutionEnvironmentJobTemplateList,
ExecutionEnvironmentActivityStreamList,
)


urls = [
url(r'^$', ExecutionEnvironmentList.as_view(), name='execution_environment_list'),
url(r'^(?P<pk>[0-9]+)/$', ExecutionEnvironmentDetail.as_view(), name='execution_environment_detail'),
url(r'^(?P<pk>[0-9]+)/unified_job_templates/$', ExecutionEnvironmentJobTemplateList.as_view(), name='execution_environment_job_template_list'),
url(r'^(?P<pk>[0-9]+)/activity_stream/$', ExecutionEnvironmentActivityStreamList.as_view(), name='execution_environment_activity_stream_list'),
]

Expand Down
8 changes: 8 additions & 0 deletions awx/api/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,14 @@ class ExecutionEnvironmentDetail(RetrieveUpdateDestroyAPIView):
swagger_topic = "Execution Environments"


class ExecutionEnvironmentJobTemplateList(SubListAPIView):

model = models.UnifiedJobTemplate
serializer_class = serializers.UnifiedJobTemplateSerializer
parent_model = models.ExecutionEnvironment
relationship = 'unifiedjobtemplates'


class ExecutionEnvironmentActivityStreamList(SubListAPIView):

model = models.ActivityStream
Expand Down

0 comments on commit d70c4f6

Please sign in to comment.