Library¶
User¶
-
class
rmaker_lib.user.
User
(username)¶ User class used to instantiate instances of user to perform various user signup/login operations.
- Parameters
username (str) – Name of User
-
forgot_password
(password=None, verification_code=None)¶ Forgot password request to reset the password.
- Parameters
password (str) – Password of user, defaults to None
verification_code (int) – Verification code received during forgot password request, defaults to None
- Raises
NetworkError – If there is a network connection issue during password reset
Exception – If there is an HTTP issue during forgot password
- Returns
True on Success
- Return type
bool
-
handle_otp_based_login
(login_session=None)¶ OTP based login for ESP RainMaker.
- Parameters
login_session (str) – Session param received in first login request
- Raises
NetworkError – If there is a network connection issue during login
Exception – If there is an HTTP issue during login or JSON format issue in HTTP response
AuthenticationError – If login failed with the given parameters
- Returns
rmaker_lib.session.Session
on Success- Return type
Dict
-
login
(password=None)¶ User login to the ESP Rainmaker.
- Parameters
password (str) – Password of user, defaults to None
- Raises
NetworkError – If there is a network connection issue during login
Exception – If there is an HTTP issue during login or JSON format issue in HTTP response
AuthenticationError – If login failed with the given parameters
- Returns
rmaker_lib.session.Session
on Success- Return type
object
-
signup
(code)¶ Sign up of new User for ESP Rainmaker.
- Parameters
code (int) – Verification code received in signup request for user
- Raises
NetworkError – If there is a network connection issue during signup
Exception – If there is an HTTP issue during signup
- Returns
True on Success
- Return type
bool
-
signup_request
(password)¶ Sign up request of new User for ESP Rainmaker.
- Parameters
password (str) – Password to set for new user
- Raises
NetworkError – If there is a network connection issue during signup request
Exception – If there is an HTTP issue during signup request
- Returns
True on Success
- Return type
bool
Session¶
-
class
rmaker_lib.session.
Session
¶ Session class for logged in user.
-
get_mqtt_host
()¶ Get the MQTT Host endpoint.
- Raises
NetworkError – If there is a network connection issue while getting MQTT Host endpoint
Exception – If there is an HTTP issue while getting MQTT host or JSON format issue in HTTP response
- Returns
MQTT Host on Success, None on Failure
- Return type
str | None
-
get_nodes
()¶ Get list of all nodes associated with the user.
- Raises
NetworkError – If there is a network connection issue while getting nodes associated with user
Exception – If there is an HTTP issue while getting nodes
- Returns
Nodes associated with user on Success
- Return type
dict
-
get_user_details
()¶ Get details of current logged-in user
- Raises
SSLError – If there is an SSL issue
HTTPError – If the HTTP response is an HTTPError
NetworkError – If there is a network connection issue
Timeout – If there is a timeout issue
RequestException – If there is an issue during the HTTP request
Exception – If there is an HTTP issue while getting user details or JSON format issue in HTTP response
- Returns
HTTP response on Success
- Return type
dict
-
logout
()¶ Logout current logged-in user
- Raises
SSLError – If there is an SSL issue
HTTPError – If the HTTP response is an HTTPError
NetworkError – If there is a network connection issue
Timeout – If there is a timeout issue
RequestException – If there is an issue during the HTTP request
Exception – If there is an HTTP issue while logging out or JSON format issue in HTTP response
- Returns
HTTP response on Success
- Return type
dict
-
Node¶
-
class
rmaker_lib.node.
Node
(nodeid, session)¶ Node class used to instantiate instances of node to perform various node operations.
- Parameters
nodeid (str) – Node Id of node
session (object) –
rmaker_lib.session.Session
-
add_user_for_sharing
(data)¶ Perform sharing operations -
Request to add user for sharing nodes
- Parameters
data (dict) – 1. To add nodes - Data containing user_name and nodes as keys
- Raises
SSLError – If there is an SSL issue
HTTPError – If the HTTP response is an HTTPError
NetworkError – If there is a network connection issue
Timeout – If there is a timeout issue
RequestException – If there is an issue during the HTTP request
Exception – If there is an HTTP issue while performing sharing operation or JSON format issue in HTTP response
- Returns
HTTP response on Success
- Return type
dict
-
add_user_node_mapping
(secret_key)¶ Add user node mapping.
- Parameters
secret_key (str) – The randomly generated secret key that will be used for User-Node mapping
- Raises
NetworkError – If there is a network connection issue while adding user node mapping
Exception – If there is an HTTP issue while adding user node mapping or JSON format issue in HTTP response
- Returns
Request Id on Success, None on Failure
- Return type
str | None
-
get_mapping_status
(request_id)¶ Check status of user node mapping request.
- Parameters
requestId (str) – Request Id
- Raises
NetworkError – If there is a network connection issue while getting user node mapping status
Exception – If there is an HTTP issue while getting user node mapping status or JSON format issue in HTTP response
- Returns
Request Status on Success, None on Failure
- Type
str | None
-
get_node_config
()¶ Get node configuration.
- Raises
NetworkError – If there is a network connection issue while getting node configuration
Exception – If there is an HTTP issue while getting node config
- Returns
Configuration of node on Success
- Return type
dict
-
get_node_params
()¶ Get parameters of the node.
- Raises
NetworkError – If there is a network connection issue while getting node params
Exception – If there is an HTTP issue while getting node params or JSON format issue in HTTP response
- Returns
Node Parameters on Success, None on Failure
- Return type
dict | None
-
get_node_status
()¶ Get online/offline status of the node.
- Raises
NetworkError – If there is a network connection issue while getting node status
Exception – If there is an HTTP issue while getting node status
- Returns
Status of node on Success
- Return type
dict
-
get_nodeid
()¶ Get nodeid of device
- Returns
Node Id of node on Success
- Return type
str
Get request sent to share nodes with user
- Parameters
params (dict) – Query parameters containing request_id and primary_user as keys
- Raises
SSLError – If there is an SSL issue
HTTPError – If the HTTP response is an HTTPError
NetworkError – If there is a network connection issue
Timeout – If there is a timeout issue
RequestException – If there is an issue during the HTTP request
Exception – If there is an HTTP issue while getting sharing request or JSON format issue in HTTP response
- Returns
HTTP response on Success
- Return type
dict
-
get_sharing_details_of_nodes
()¶ Get sharing details of nodes associated with user
- Raises
SSLError – If there is an SSL issue
HTTPError – If the HTTP response is an HTTPError
NetworkError – If there is a network connection issue
Timeout – If there is a timeout issue
RequestException – If there is an issue during the HTTP request
Exception – If there is an HTTP issue while getting shared nodes or JSON format issue in HTTP response
- Returns
HTTP response on Success
- Return type
dict
Remove/Cancel request sent to share nodes with user
- Parameters
req_id – Id of sharing request
- Raises
SSLError – If there is an SSL issue
HTTPError – If the HTTP response is an HTTPError
NetworkError – If there is a network connection issue
Timeout – If there is a timeout issue
RequestException – If there is an issue during the HTTP request
Exception – If there is an HTTP issue while removing sharing request or JSON format issue in HTTP response
- Returns
HTTP response on Success
- Return type
dict
Remove user from shared nodes
- Parameters
data (dict) – Data containing user_name and nodes as keys
- Raises
SSLError – If there is an SSL issue
HTTPError – If the HTTP response is an HTTPError
NetworkError – If there is a network connection issue
Timeout – If there is a timeout issue
RequestException – If there is an issue during the HTTP request
Exception – If there is an HTTP issue while removing shared nodes or JSON format issue in HTTP response
- Returns
HTTP response on Success
- Return type
dict
-
remove_user_node_mapping
()¶ Remove user node mapping request.
- Raises
NetworkError – If there is a network connection issue while removing user node mapping
Exception – If there is an HTTP issue while removing user node mapping or JSON format issue in HTTP response
- Returns
Request Id on Success, None on Failure
- Return type
str | None
-
request_op
(data)¶ Perform sharing operations -
Accept or decline sharing request
- Parameters
data (dict) – 1. Data containing request_id and accept as keys
- Raises
SSLError – If there is an SSL issue
HTTPError – If the HTTP response is an HTTPError
NetworkError – If there is a network connection issue
Timeout – If there is a timeout issue
RequestException – If there is an issue during the HTTP request
Exception – If there is an HTTP issue while performing request operation or JSON format issue in HTTP response
- Returns
HTTP response on Success
- Return type
dict
-
set_node_params
(data)¶ Set parameters of the node.
- Parameters
data (dict) – Parameters to be set for the node
- Raises
NetworkError – If there is a network connection issue while setting node params
Exception – If there is an HTTP issue while setting node params or JSON format issue in HTTP response
- Returns
True on Success
- Return type
bool