Product Downloads

class Downloads(api_token=None, **kwargs)[source]

The Downloads object is the primary interaction point for users to interface with Downloads API via the pyTenable library. All of the API endpoint classes that have been written will be grafted onto this class.

Parameters:
  • api_token (str, optional) – The user’s API access key for Tenable Vulnerability Management If an access key isn’t specified, then the library will attempt to read the environment variable TDL_API_TOKEN to acquire the key.

  • retries (int, optional) – The number of retries to make before failing a request. The default is 5.

  • backoff (float, optional) – If a 429 response is returned, how much do we want to backoff if the response didn’t send a Retry-After header. The default backoff is 1 second.

  • vendor (str, optional) – The vendor name for the User-Agent string.

  • product (str, optional) – The product name for the User-Agent string.

  • build (str, optional) – The version or build identifier for the User-Agent string.

  • timeout (int, optional) – The connection timeout parameter informing the library how long to wait in seconds for a stalled response before terminating the connection. If unspecified, the default is 120 seconds.

Examples

Basic Example:

>>> from tenable.dl import Downloads
>>> dl = Downloads(api_token='API_TOKEN')

Example with proper identification:

>>> dl = Downloads('API_TOKEN',
>>>     vendor='Company Name',
>>>     product='My Awesome Widget',
>>>     build='1.0.0')

Example with proper identification leveraging environment variables for access and secret keys:

>>> dl = Downloads(
>>>     vendor='Company Name', product='Widget', build='1.0.0')
details(page)[source]

Retrieves the specific download items for the page requested.

API Endpoint Documentation

Parameters:

page (str) – The name of the page to request.

Returns:

The page details.

Return type:

dict

Examples

>>> details = dl.details('nessus')
download(page, package, fobj=None)[source]

Retrieves the requested package and downloads the file.

API Endpoint Documentation

Parameters:
  • page (str) – The name of the page

  • package (str) – The package filename

  • fobj (FileObject, optional) – The file-like object to write the package to. If nothing is specified, then a BytesIO object will be used.

Returns:

The binary package

Return type:

FileObject

Examples

>>> with open('Nessus-latest.x86_64.rpm', 'wb') as pkgfile:
...     dl.download('nessus',
...         'Nessus-8.3.0-es7.x86_64.rpm', pkgfile)
list()[source]

Lists the available content pages.

API Endpoint Documentation

Returns:

The list of page resources.

Return type:

list

Examples

>>> pages = dl.list()
>>> for page in pages:
...     pprint(page)