-
Notifications
You must be signed in to change notification settings - Fork 22
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
Fix for Rest Connector for nd (Nexus Dashboard) will not work for remote authentication #132
base: main
Are you sure you want to change the base?
Conversation
…tion made domain optional in connections so that when domain is not there in testbed it defaults to DefaultAuth. And if any new domain is added then value can be specified in testbed.yaml
Overloaded get, post, put and delete so that they are backward compatible.
"""connect to the device via REST | ||
Arguments | ||
--------- | ||
timeout (int): Timeout value | ||
retries (int): Max retries on request exception (default: 3) | ||
retry_wait (int): Seconds to wait before retry (default: 10) | ||
verify (bool): defaults to False |
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.
Defaults to False, but what does it do? A brief description of what we're verifying would be ideal
log.info("Output received:\n{output}".format(output= | ||
json.dumps(output, indent=2, sort_keys=True))) |
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.
We're removing the dump? It'll make reading the output harder
api_url (string): subdirectory part of the API URL | ||
params (dict): Query string parameters | ||
data (dict): | ||
json (json) : if request header Content-Type is application/json | ||
files (dict): | ||
expected_status_code (int): Expected result | ||
timeout (int): Maximum time |
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.
Add defaults
@@ -423,49 +513,97 @@ def delete(self, api_url, expected_status_code=requests.codes.ok, | |||
timeout (int): Maximum time |
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.
Make sure to update the docstring
api_url (string): subdirectory part of the API URL | ||
params (dict): Query string parameters | ||
data (dict): | ||
json (json) : if request header Content-Type is application/json | ||
files (dict): | ||
timeout (int): Maximum time |
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.
Add defaults
if params and not json: | ||
response = self.session.delete(full_url, params=params, timeout=timeout, | ||
verify=self.verify) | ||
elif params and json: | ||
response = self.session.delete(full_url, params=params, json=json, | ||
timeout=timeout, verify=self.verify) | ||
elif json and not params: | ||
response = self.session.delete(full_url, json=json, | ||
timeout=timeout, verify=self.verify) | ||
elif data: | ||
response = self.session.delete(full_url, data=data, | ||
timeout=timeout, verify=self.verify) | ||
elif files: | ||
response = self.session.delete(full_url, files=files, | ||
timeout=timeout, verify=self.verify) | ||
else: | ||
response = self.session.delete(full_url, timeout=timeout, verify=self.verify) |
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.
Same
Co-authored-by: Thomas Ryan <[email protected]>
Co-authored-by: Thomas Ryan <[email protected]>
Updated doc for verify
Addressed Are we not able to pass None to the values? IE, surely if json is None we can still do self.session.post(..., json=None)? Would be better than having this large if/else structure
Co-authored-by: Thomas Ryan <[email protected]>
Co-authored-by: Thomas Ryan <[email protected]>
Redacted default password in source code.
Fix for domain in testbed file made it optional so that it backward compatible.
Added get, post, put, delete with params, data, files, json and removed expected_status_code and return type requests.Response
#131