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

feat: Adding 'hosts' endpoint #865

Conversation

jonathan-guihard
Copy link
Contributor

@jonathan-guihard jonathan-guihard commented Jan 15, 2025

Description

Added list function for hosts API endpoint.

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

  • Tested against Tenable SC directly
❯ pip freeze | grep pyTenable
pyTenable @ git+https://github.com/tenable/pytenable.git@77f73a937326a48e77e3f138e1530365ebb1cfe8

❯ python3
>>> import os
>>> from pprint import pprint
>>> from tenable.sc import TenableSC
>>> sc = TenableSC(
...     os.environ["tenable_host"],
...     access_key=os.environ["TENABLE_CREDS_USR"],
...     secret_key=os.environ["TENABLE_CREDS_PSW"],
... )
>>> hosts = sc.hosts.list()
>>> pprint(hosts[0])
{'firstSeen': '1650672000',
 'id': '9200806',
 'ipAddress': 'REDACTED',
 'lastSeen': '1736601052',
 'name': 'REDACTED',
 'os': None,
 'tenableUUID': None,
 'uuid': '19044052-422d-4066-95ae-c1f6dae6ffd9'}
>>> hosts_filter = sc.hosts.list(fields=['name', 'uuid', 'ipAddress'])
>>> pprint(hosts_filter[0])
{'id': '9200806',
 'ipAddress': 'REDACTED',
 'name': 'REDACTED,
 'uuid': '19044052-422d-4066-95ae-c1f6dae6ffd9'}

Test Configuration:

  • Python Version(s) Tested: 3.13
  • Tenable.sc version (if necessary): 6.5.1

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@jonathan-guihard jonathan-guihard requested a review from a team as a code owner January 15, 2025 17:11
@jonathan-guihard
Copy link
Contributor Author

@SteveMcGrath hey :)

The snyk check is failing, would it be possible to have a look please?

@SteveMcGrath
Copy link
Contributor

awesome work, amusingly we've been working on the same thing. The snyk check will always fail on a non-local PR as it requires secrets that you dont have access to.

@jonathan-guihard
Copy link
Contributor Author

awesome work, amusingly we've been working on the same thing.

I've only implemented the list feature as it's the one I needed 😄

@jonathan-guihard
Copy link
Contributor Author

Closing the PR - Duplicate of #866

@jonathan-guihard jonathan-guihard deleted the feat/adding-hosts-endpoint branch January 16, 2025 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants