From 1b264011a23f1c5d4bf2ce69999b4e9c69593e84 Mon Sep 17 00:00:00 2001 From: Jeff Bradberry Date: Fri, 3 Apr 2020 16:21:26 -0400 Subject: [PATCH] Enable interconnections between WFJT Nodes --- awxkit/awxkit/api/pages/api.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/awxkit/awxkit/api/pages/api.py b/awxkit/awxkit/api/pages/api.py index 062bad95ed..e6561e5a9c 100644 --- a/awxkit/awxkit/api/pages/api.py +++ b/awxkit/awxkit/api/pages/api.py @@ -31,6 +31,7 @@ EXPORTABLE_RESOURCES = [ EXPORTABLE_RELATIONS = [ 'Roles', 'NotificationTemplates', + 'WorkflowJobTemplateNodes', 'Credentials', ] @@ -38,8 +39,10 @@ EXPORTABLE_RELATIONS = [ EXPORTABLE_DEPENDENT_OBJECTS = [ 'Labels', 'SurveySpec', - 'WorkflowJobTemplateNodes', 'Schedules', + # WFJT Nodes are a special case, we want full data for the create + # view and natural keys for the attach views. + 'WorkflowJobTemplateNodes', ] @@ -124,19 +127,19 @@ class ApiV2(base.Base): related = {} for key, related_endpoint in asset.related.items(): - if key in asset.json or not related_endpoint: + if key in options or not related_endpoint: continue rel = related_endpoint._create() - if rel.__class__.__name__ in EXPORTABLE_RELATIONS: + related_options = self._get_options(related_endpoint) + if related_options is None: # This is a read-only endpoint. + continue + is_attach = 'id' in related_options # This is not a create-only endpoint. + + if rel.__class__.__name__ in EXPORTABLE_RELATIONS and is_attach: by_natural_key = True - related_options = self._get_options(related_endpoint) - if related_options is None: - continue - if 'id' not in related_options: - continue # This is a read-only or create-only endpoint. elif rel.__class__.__name__ in EXPORTABLE_DEPENDENT_OBJECTS: - by_natural_key, related_options = False, None + by_natural_key = False else: continue