api.http_methods

Module Contents

api.http_methods.STANDARD_HEADERS[source]
api.http_methods.STANDARD_TIMEOUT = 10[source]
api.http_methods.VALID_STATUS_CODES = [200, 201, 202, 203, 204, 205, 206, 207, 208, 226][source]
class api.http_methods.HttpMethods(session, url)[source]

Bases: object

HTTP Methods for vManage API Interaction

Provides a consistent interaction with the vManage REST API. Contains error handling for common HTTP interaction issues.

request(self, method, headers=None, payload=None, files=None, timeout=STANDARD_TIMEOUT)[source]

Performs HTTP REST API Call.

Parameters
  • method (str) – DELETE, GET, POST, PUT

  • headers (dict) – Use standard vManage header provided in module or custom header for specific API interaction

  • payload (str) – A formatted string to be delivered to vManage via POST or PUT REST call

  • file (obj) – A file to be sent to vManage

Returns

A parsable dictionary containing the full

response from vManage for an interaction

Return type

result (dict)

Raises
  • JSONDecodeError – Payload format error.

  • ConnectionError – Connection error.

  • HTTPError – An HTTP error occurred.

  • URLRequired – A valid URL is required to make a request.

  • TooManyRedirects – Too many redirects.

  • Timeout – The request timed out.

  • RequestException – There was an ambiguous exception.