-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixes #67 #86
fixes #67 #86
Changes from 2 commits
995cda7
8b98158
6553a0c
4579692
c2da247
c0e37fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,14 @@ | |
required: False | ||
default: True | ||
type: bool | ||
populate_root: | ||
description: | ||
- Whether or not to populate data in the in the root (e.g. hostvars[inventory_hostname]) or within the | ||
'data' key (e.g. hostvars[inventory_hostname]['data']). Beware, that the root keys provided by the query | ||
will overwrite any root keys already present, leverage the GraphQL alias feature to avoid issues. | ||
required: False | ||
default: False | ||
type: bool | ||
""" | ||
|
||
EXAMPLES = """ | ||
|
@@ -82,22 +90,23 @@ | |
site_name: den | ||
query_string: | | ||
query ($site_name:String!) { | ||
sites (name: $site_name) { | ||
sites (name: $site_name) { | ||
id | ||
name | ||
region { | ||
name | ||
} | ||
} | ||
} | ||
} | ||
|
||
# Get Response with variables | ||
# Get Response with variables and set to root keys | ||
- name: Obtain list of devices at site in variables from Nautobot | ||
networktocode.nautobot.query_graphql: | ||
url: http://nautobot.local | ||
token: thisIsMyToken | ||
query: "{{ query_string }}" | ||
variables: "{{ variables }}" | ||
populate_root: "yes" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't that be boolean There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In ansible they are equivalent There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I know, unquoted |
||
""" | ||
|
||
RETURN = """ | ||
|
@@ -145,6 +154,7 @@ def main(): | |
token=dict(required=False, type="str", no_log=True, default=None), | ||
url=dict(required=False, type="str", default=None), | ||
validate_certs=dict(required=False, type="bool", default=True), | ||
populate_root=dict(required=False, type="bool", default=False), | ||
itdependsnetworks marked this conversation as resolved.
Show resolved
Hide resolved
|
||
), | ||
# Set to true as this is a read only API, this may need to change or have significant changes when Mutations are | ||
# added to the GraphQL endpoint of Nautobot | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need the else here as we should be returning the data regardless. The flag should just set the facts or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had that at first, it seemed like duplicate, what say everyone else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go ahead and remove the else, remove the indent for the results. Then the data key will be populated regardless, whether it has data or it is
None
.