mirror of
https://github.com/ansible/awx.git
synced 2026-04-11 21:19:22 -02:30
Merge pull request #4899 from ryanpetrello/cli-improved-name-lookups
attempt to properly map more foreign keys to named lookups Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
@@ -40,6 +40,11 @@ def pk_or_name(v2, model_name, value, page=None):
|
|||||||
if model_name in UNIQUENESS_RULES:
|
if model_name in UNIQUENESS_RULES:
|
||||||
identity = UNIQUENESS_RULES[model_name][-1]
|
identity = UNIQUENESS_RULES[model_name][-1]
|
||||||
|
|
||||||
|
# certain related fields follow a pattern of <foo>_<model> e.g.,
|
||||||
|
# insights_credential, target_credential etc...
|
||||||
|
if not page and '_' in model_name:
|
||||||
|
return pk_or_name(v2, model_name.split('_')[-1], value, page)
|
||||||
|
|
||||||
if page:
|
if page:
|
||||||
results = page.get(**{identity: value})
|
results = page.get(**{identity: value})
|
||||||
if results.count == 1:
|
if results.count == 1:
|
||||||
|
|||||||
Reference in New Issue
Block a user