Base Platform

The APIPlatform class is the base class that all platform packages will inherit from. Throughout pyTenable v1, packages will be transitioning to using this base class over the original APISession class.

class APIPlatform(**kwargs)[source]

Base class for all API Platform packages. This class handles all of the base connection logic.

Parameters
  • adaptor (Object, optional) – A Requests Session adaptor to bind to the session object.

  • 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. If left unspecified, the default is 1 second.

  • box (bool, optional) – Should responses be passed through Box? If left unspecified, the default is True.

  • box_attrs (dict, optional) – Any additional attributes to pass to the Box constructor for this session? For a list of attributes that can be sent, please refer to the Box documentation for more information.

  • build (str, optional) – The build number to put into the User-Agent string.

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

  • proxies (dict, optional) – A dictionary detailing what proxy should be used for what transport protocol. This value will be passed to the session object after it has been either attached or created. For details on the structure of this dictionary, consult the proxies section of the Requests documentation.

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

  • session (requests.Session, optional) – Provide a pre-built session instead of creating a requests session at instantiation.

  • squash_camel (bool, optional) – Should the responses have CamelCase responses be squashed into snake_case? If left unspecified, the default value is False. Note that this will only work when Box is enabled.

  • ssl_verify (bool, optional) – If SSL Verification needs to be disabled (for example when using a self-signed certificate), then this parameter should be set to False to disable verification and mask the Certificate warnings.

  • url (str, optional) – The base URL that the paths will be appended onto.

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

delete(path: str, **kwargs) Union[box.box.Box, box.box_list.BoxList, requests.models.Response]

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
Returns

requests.Response or box.Box

If the request was informed to attempt to “boxify” the response and the response was JSON data, then a Box will be returned. In all other scenarios, a Response object will be returned.

Examples

>>> api = APISession()
>>> resp = api.delete('/')
get(path: str, **kwargs) Union[box.box.Box, box.box_list.BoxList, requests.models.Response]

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
Returns

requests.Response or box.Box

If the request was informed to attempt to “boxify” the response and the response was JSON data, then a Box will be returned. In all other scenarios, a Response object will be returned.

Examples

>>> api = APISession()
>>> resp = api.get('/')
head(path: str, **kwargs) Union[box.box.Box, box.box_list.BoxList, requests.models.Response]

Initiates an HTTP HEAD request using the specified path. Refer to the requests.request for more detailed information on what keyword arguments can be passed:

Parameters
Returns

requests.Response or box.Box

If the request was informed to attempt to “boxify” the response and the response was JSON data, then a Box will be returned. In all other scenarios, a Response object will be returned.

Examples

>>> api = APISession()
>>> resp = api.head('/')
patch(path: str, **kwargs) Union[box.box.Box, box.box_list.BoxList, requests.models.Response]

Initiates an HTTP PATCH request using the specified path. Refer to the requests.request for more detailed information on what keyword arguments can be passed:

Parameters
Returns

requests.Response or box.Box

If the request was informed to attempt to “boxify” the response and the response was JSON data, then a Box will be returned. In all other scenarios, a Response object will be returned.

Examples

>>> api = APISession()
>>> resp = api.patch('/')
post(path: str, **kwargs) Union[box.box.Box, box.box_list.BoxList, requests.models.Response]

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
Returns

requests.Response or box.Box

If the request was informed to attempt to “boxify” the response and the response was JSON data, then a Box will be returned. In all other scenarios, a Response object will be returned.

Examples

>>> api = APISession()
>>> resp = api.post('/')
put(path: str, **kwargs) Union[box.box.Box, box.box_list.BoxList, requests.models.Response]

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
Returns

requests.Response or box.Box

If the request was informed to attempt to “boxify” the response and the response was JSON data, then a Box will be returned. In all other scenarios, a Response object will be returned.

Examples

>>> api = APISession()
>>> resp = api.put('/')