summaryrefslogtreecommitdiffstats
path: root/awxkit
diff options
context:
space:
mode:
authorJeff Bradberry <jeff.bradberry@gmail.com>2022-03-18 15:32:33 +0100
committerJeff Bradberry <jeff.bradberry@gmail.com>2022-03-18 15:32:33 +0100
commitb562d5cc88e5e927d85027df83d9fa9bbbb8ac72 (patch)
treeb47b972ef420f08beea3a9e35cdac9e89cda0054 /awxkit
parentMerge pull request #11917 from nixocio/ui_survey_issue (diff)
downloadawx-b562d5cc88e5e927d85027df83d9fa9bbbb8ac72.tar.xz
awx-b562d5cc88e5e927d85027df83d9fa9bbbb8ac72.zip
Look up the correct top-level resource name when reconstructing foreign keys
during an awx-cli export.
Diffstat (limited to 'awxkit')
-rw-r--r--awxkit/awxkit/api/pages/api.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/awxkit/awxkit/api/pages/api.py b/awxkit/awxkit/api/pages/api.py
index b2c7a462ad..1633cf59a0 100644
--- a/awxkit/awxkit/api/pages/api.py
+++ b/awxkit/awxkit/api/pages/api.py
@@ -100,7 +100,13 @@ class ApiV2(base.Base):
else:
if post_fields[key]['type'] == 'id' and _page.json.get(key) is not None:
log.warning("Related link %r missing from %s, attempting to reconstruct endpoint.", key, _page.endpoint)
- resource = getattr(self, key, None)
+ res_pattern, resource = getattr(resources, key, None), None
+ if res_pattern:
+ try:
+ top_level = res_pattern.split('/')[3]
+ resource = getattr(self, top_level, None)
+ except IndexError:
+ pass
if resource is None:
log.error("Unable to infer endpoint for %r on %s.", key, _page.endpoint)
continue