pages
The following methods allow for interaction into the Downloads Pages API
Methods available on downloads.pages
:
-
class
PageAPI
(api)[source]
-
details
(page)[source]
Retrieves the specific download items for the page requested.
Parameters: | page (str) – The name of the page to request. |
Returns: | The page details. |
Return type: | dict |
Examples
>>> details = downloads.pages.details('nessus')
-
download
(page, package, fobj=None)[source]
Retreives the requested package and downloads the file.
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: | FileObject
|
Examples
>>> with open('Nessus-latest.x86_64.rpm', 'wb') as pkgfile:
... downloads.pages.download('nessus',
... 'Nessus-8.3.0-es7.x86_64.rpm', pkgfile)
-
list
()[source]
Lists the available content pages.
Returns: | The list of page resources. |
Return type: | list |
Examples
>>> pages = downloads.pages.list()
>>> for page in pages:
... pprint(page)
Raw HTTP Calls
Even though the Downloads
object pythonizes the downloads API for
you, there may still bee the occasional need to make raw HTTP calls to the
Downloads portal API. The methods listed below aren’t run through any
naturalization by the library aside from the response code checking. These
methods effectively route directly into the requests session. The responses
will be Response objects from the requests
library. In all cases, the path
is appended to the base url
parameter that the Downloads
object was
instantiated with.
Example:
resp = downloads.get('pages')
-
class
Downloads
(api_key, url=None, retries=None, backoff=None, ua_identity=None, session=None, proxies=None, vendor=None, product=None, build=None)[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_key (str, optional) – The user’s API access key for the Downloads API.
- url (str, optional) – The base URL that the paths will be appended onto. The default
is
https://www.tenable.com/downloads/api/v2
- retries (int, optional) – The number of retries to make before failing a request. The
default is
3 .
- 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.
- ua_identity (str, optional) – An application identifier to be added into the User-Agent string
for the purposes of application identification.
|
Examples
>>> from tenable.downloads import Downloads
>>> downloads = Downloads({DL_API_KEY})
-
get
(path, **kwargs)
Initiates an HTTP GET request using the specified path. Refer to
requests.request
for more detailed information on what
keyword arguments can be passed:
Parameters: |
- path (str) – The path to be appended onto the base URL for the request.
- **kwargs (dict) – Keyword arguments to be passed to the Requests Sessions request
method.
|
Returns: | requests.Response
|
-
post
(path, **kwargs)
Initiates an HTTP POST request using the specified path. Refer to the
requests.request
for more detailed information on what
keyword arguments can be passed:
Parameters: |
- path (str) – The path to be appented onto the base URL for the request.
- **kwargs (dict) – Keyword arguments to be passed to the Requests Sessions request
method.
|
Returns: | requests.Response
|
-
put
(path, **kwargs)
Initiates an HTTP PUT request using the specified path. Refer to the
requests.request
for more detailed information on what
keyword arguments can be passed:
Parameters: |
- path (str) – The path to be appended onto the base URL for the request.
- **kwargs (dict) – Keyword arguments to be passed to the Requests Sessions request
method.
|
Returns: | requests.Response
|
-
delete
(path, **kwargs)
Initiates an HTTP DELETE request using the specified path. Refer to the
requests.request
for more detailed information on what
keyword arguments can be passed:
Parameters: |
- path (str) – The path to be appended onto the base URL for the request.
- **kwargs (dict) – Keyword arguments to be passed to the Requests Sessions request
method.
|
Returns: | requests.Response
|