client
This module manages the user identity and to perform the requests to the API web services.
Client
A Client handles html requests.
__init__(self, config_file=None, config_dict=None, timeout=60)
special
Initialize Client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config_file |
str |
A path to a configuration file. |
None |
config_dict |
Dict[str, str] |
A configuration dictionary. |
None |
timeout |
int |
Combined connect and read timeout for HTTP requests, in seconds. |
60 |
__str__(self)
special
Produce informal representation of the Client object.
Returns:
Type | Description |
---|---|
str |
An informal representation of the Client object. |
get_braincube_infos(self)
Get the information about the braincubes available to the client.
Returns:
Type | Description |
---|---|
Dict[str, Any] |
Return the dictionary of braincubes available to the client. |
has_placeholder_in_braincube_url(self)
Indicates whether or not braincube_base_url contains a placeholder.
The placeholder format is given by constants.BRAINCUBE_NAME_PLACEHOLDER.
Returns:
Type | Description |
---|---|
|
Returns a boolean indicating whether or not braincube_base_url contains a placeholder |
request_ws(self, path, headers=None, body_data=None, rtype='GET', api=True, response_as_json=True, braincube_name='')
Make a request at a given path on the client's domain.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str |
Path on the domain. |
required |
headers |
Dict[str, Any] |
Headers of the request. |
None |
body_data |
Any |
Data to associate to the request. |
None |
rtype |
str |
Request type (GET, POST). |
'GET' |
api |
bool |
Requests the API server on the domain. |
True |
response_as_json |
bool |
parse a json output to a python dictionary. |
True |
braincube_name |
str |
name of the Braincube you want to use to do this request. Usefull when you have {braincube-name} in your base URL |
'' |
Returns:
Type | Description |
---|---|
Dict[str, Any] |
The request's json output or the full response. |
get_instance(config_file=None, config_dict=None)
Static method to get the client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config_file |
str |
A path to a configuration file. |
None |
config_dict |
Dict[str, str] |
A configuration dictionary. |
None |
Returns:
Type | Description |
---|---|
Client |
A client object. |
request_ws(path, headers=None, body_data=None, rtype='GET', api=True, response_as_json=True, braincube_name='')
Make a request at a given path on the client's domain.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str |
Path on the domain. |
required |
headers |
Dict[str, Any] |
Headers of the request. |
None |
body_data |
Any |
Data to associate to the request. |
None |
rtype |
str |
Request type (GET, POST). |
'GET' |
api |
bool |
Requests the API server on the domain. |
True |
response_as_json |
bool |
parse a json output to a python dictionary. |
True |
braincube_name |
str |
name of the braincube on which is made the request, useful if you use a placeholder in your config |
'' |
Returns:
Type | Description |
---|---|
Dict[str, Any] |
The request's json output or the full response. |