graphspace_python.api package

Submodules

graphspace_python.api.client module

class graphspace_python.api.client.GraphSpace(username, password)[source]

Bases: object

GraphSpace client class.

Connects the user with GraphSpace.

Makes request to the GraphSpace REST APIs and returns the response.

Parameters:
  • username (str) – Email of the user.
  • password (str) – Password of the user.

Example

Initialising a GraphSpace client can be done in the following way:

>>> from graphspace_python.api.client import GraphSpace
>>> graphspace = GraphSpace('[email protected]', 'user1')
auth_token

str – Base64 encoded username and password.

username

str – Email of user.

api_host

str – Host address of GraphSpace REST API.

set_api_host(host)[source]

Manually set host address of GraphSpace REST APIs.

Parameters:host (str) – Host address of GraphSpace APIs.

Example

>>> from graphspace_python.api.client import GraphSpace
>>> graphspace = GraphSpace('[email protected]', 'user1')
>>> graphspace.set_api_host('localhost:8000')

graphspace_python.api.config module

graphspace_python.api.errors module

exception graphspace_python.api.errors.BadRequest(status_code, reason, response)[source]

Bases: graphspace_python.api.errors.GraphSpaceError

class graphspace_python.api.errors.ErrorHandler[source]

Bases: object

ErrorHandler class.

Exception handling class for GraphSpace API’s HTTP errors.

raise_error(error, response)[source]

Raises exception based on the ‘error_code’ received in response when any HTTP error occurs in API call.

Parameters:
  • error (object) – HTTPError object.
  • response (dict) – Response dict having error details from the API call.
Raises:

GraphSpaceError – If an error response is received from the API call, it raises any one of the GraphSpaceError depending upon the error code.

exception graphspace_python.api.errors.GraphSpaceError(status_code, reason, response)[source]

Bases: Exception

GraphSpaceError class.

Base error class for the GraphSpace HTTP errors.

status_code

int – HTTP error status code.

reason

str – Reason of HTTP error.

error_code

int – Error code received from GraphSpace.

error_message

str – Error message received from GraphSpace.

exception graphspace_python.api.errors.LayoutNameAlreadyExists(status_code, reason, response)[source]

Bases: graphspace_python.api.errors.GraphSpaceError

exception graphspace_python.api.errors.UserAlreadyExists(status_code, reason, response)[source]

Bases: graphspace_python.api.errors.GraphSpaceError

exception graphspace_python.api.errors.UserNotAuthenticated(status_code, reason, response)[source]

Bases: graphspace_python.api.errors.GraphSpaceError

exception graphspace_python.api.errors.UserNotAuthorised(status_code, reason, response)[source]

Bases: graphspace_python.api.errors.GraphSpaceError

Module contents