The vov_rest_v3.py Python Library Module
The Accelerator software package provides a Python library module called vov_rest_v3.py to make REST API usage from Python more convenient. The module implements a VOVRestV3 Python class with member functions described in the following text box. These functions hide the details associated with authenticating, session handling, and error handling. More example programs follow that utilize this convenient Python library layer.
VOVRestV3 Python Class Description
The VOVRestV3 Python class provides an interface to the Accelerator v3 REST API.
- Location
- $VOVDIR/../common/scripts/python
- Member Functions
-
- authorize (url, username=’’, password=’’)
- The vovserver scheduling server authenticates a user for a
VOVRestV3 and obtains a validating access token behind the scenes,
storing it in the VOVRestV3 object.
- Positional Arguments
- url – (string) the URL as returned by nc cmd vovbrowser
- Keyword Arguments
- username – (string) user name, usually the same as the Linux user name known to vovserver. If this argument is not provided it defaults to the current user identified by $USER
- Return Value
- None. Raises exceptions upon failure.
- submitRequest (method, url, queryParams={}, jsonData={})
- Submits a REST/ HTTP request to the server.
- Positional Arguments
- method – (string) one of: “GET”, “POST”, “PUT”, “DELETE”, “PATCH”.
- Keyword Arguments
- queryParams – (dictionary) keywords and values in string fromat for GET requests
- Return Value
- (string) The HTTP request response text.
- getJWT()
- Retrieve the JSON Web Token (JWT) for the object.
- setJWT(token)
- Replace the JSON Web Token (JWT) for the object.
- Positional Arguments
- token – (string) the replacement JWT to be remembered in the object and used for subsequent REST requests
- Return Value
- None.