Skip to content

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