From 6b3befcb942acfb21b17e2b7dfb0af103f49e522 Mon Sep 17 00:00:00 2001 From: Jeff Bradberry Date: Thu, 26 Mar 2020 15:25:51 -0400 Subject: [PATCH] Optionally add the webhook_credential link to related on JTs and WFJTs. --- awx/api/serializers.py | 4 ++++ .../unit/api/serializers/test_job_template_serializers.py | 1 + 2 files changed, 5 insertions(+) diff --git a/awx/api/serializers.py b/awx/api/serializers.py index bb488d368a..797e3f6bc2 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -2900,6 +2900,8 @@ class JobTemplateSerializer(JobTemplateMixin, UnifiedJobTemplateSerializer, JobO res['callback'] = self.reverse('api:job_template_callback', kwargs={'pk': obj.pk}) if obj.organization_id: res['organization'] = self.reverse('api:organization_detail', kwargs={'pk': obj.organization_id}) + if obj.webhook_credential_id: + res['webhook_credential'] = self.reverse('api:credential_detail', kwargs={'pk': obj.webhook_credential_id}) return res def validate(self, attrs): @@ -3390,6 +3392,8 @@ class WorkflowJobTemplateSerializer(JobTemplateMixin, LabelsListMixin, UnifiedJo ) if obj.organization: res['organization'] = self.reverse('api:organization_detail', kwargs={'pk': obj.organization.pk}) + if obj.webhook_credential_id: + res['webhook_credential'] = self.reverse('api:credential_detail', kwargs={'pk': obj.webhook_credential_id}) return res def validate_extra_vars(self, value): diff --git a/awx/main/tests/unit/api/serializers/test_job_template_serializers.py b/awx/main/tests/unit/api/serializers/test_job_template_serializers.py index 2287348d5f..00ba863987 100644 --- a/awx/main/tests/unit/api/serializers/test_job_template_serializers.py +++ b/awx/main/tests/unit/api/serializers/test_job_template_serializers.py @@ -31,6 +31,7 @@ def job_template(mocker): mock_jt.validation_errors = mock_JT_resource_data mock_jt.webhook_service = '' mock_jt.organization_id = None + mock_jt.webhook_credential_id = None return mock_jt