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('user1@example.com', 'user1')
auth_token

Base64 encoded username and password.

Type:str
username

Email of user.

Type:str
api_host

Host address of GraphSpace REST API.

Type:str
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('user1@example.com', '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

HTTP error status code.

Type:int
reason

Reason of HTTP error.

Type:str
error_code

Error code received from GraphSpace.

Type:int
error_message

Error message received from GraphSpace.

Type:str
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