pyaoscx.api module

class pyaoscx.api.API

Bases: abc.ABC

Generic API class, that handles REST API versioning.

classmethod create(target_version)

Translate the version string name to a valid python symbol.

Parameters:
  • cls – API Class object.
  • target_version – String with the API Version.
Return api:

API object.

get_index(obj)
Method used to obtain the correct format of the objects information
which depends on the Current API version.
Parameters:obj – PyaoscxModule object.
Return info:Dictionary in the form of: “keepalive_vrf”: { “keepalive_name”: “Resource uri”, }.
get_keys(response_data, module_name=None)
Given a response_data obtain the indices of said dictionary and return
them. Get keys should be used for only one element in the dictionary.
Parameters:response_data – a dictionary object in the form of: { “idx_1,idx_2”: “/rest/v10.0X/system/<module>/<idx_1>,<idx_2>”, }
Return indices:List of indices.
get_module(session, module, index_id=None, **kwargs)

Create a module object given a response data and the module’s type.

Parameters:
  • session – pyaoscx.Session object used to represent a logical connection to the device
  • module – Name representing the module which is about to be created
  • index_id – The module index_id or ID
Return object:

Return object same as module

get_module_class(session, name)

Get a module’s class given a session, and the module’s name.

Parameters:
  • session – pyaoscx.Session object used to represent a logical connection to the device.
  • name – Name of the module’s class to be imported.
get_uri_from_data(data)
Given a response data, create a list of URI items. In this Version the
data is a dict.
Parameters:data – Dictionary containing URI data in the form of: { ‘<name>’: ‘/rest/v10.0X/system/<module>/<name>’, ‘<name>’: ‘/rest/v10.0X/system/<module>/<name>’, ‘<name>’: ‘/rest/v10.0X/system/<module>/<name>’ }.
Return uri_list:
 a list containing the input dictionary’s values. Example: [ ‘/rest/v10.0X/system/<module>/<name>’, ‘/rest/v10.0X/system/<module>/<name>’ ].
license = 'Apache-2.0'
valid_depth(depth)

Verifies if given depth is valid for the current API version.

Parameters:depth – Integer
Return valid:Boolean True if depth is valid.