Skip to content
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

Sample for enabling/disabling hardware sensors. #71

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Dreadth
Copy link

@Dreadth Dreadth commented Jul 18, 2022

The payload for the verbs (Enable|Disable)Sensors was not straightforward. I spent a lot of time trolling thwack and swagger, trying to figure out how to format the payload to be used with orionsdk-python. Now that I have figured it out, I believe this information could be helpful to someone else.

Copy link
Contributor

@danjagnow danjagnow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great sample! Thanks for providing this. I have a couple of minor comments.

# Below is what the payload should look like:
payload_template = [
{'HardwareInfoID': int, 'HardwareCategoryStatusID': int, 'UniqueName': str},
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 3 lines should be prefixed with # to make them part of the comment. We don't want to actually create payload_template.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Suggestion. Commented out these lines.

"SELECT NodeID, IPAddress "
"FROM Orion.Nodes "
f"WHERE IPAddress = '{ip_address}' "
)['results'][0]['NodeID']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be useful to add a comment to explain that this sample assumes this query will return exactly one matching record.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Suggestion. Added a comment to clarify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants