Alarms¶
Baze(user=None, password=None, api_key=DEFAULT_API_KEY, **kwargs)
¶
Top level class used to connect to Bazefield. It will create the connection to Bazefield and then allow for all the APIs to be called by it's attributes.
By default no arguments needs to be provided as the package will use the default API key to connect to Bazefield, but it can be overridden. The following methods of login can be used:
- user and password: To use it, user and password must be provided and api_key must be set to None.
- api_key: To use it, pass the desired api_key or don't pass this argument to use the default one.
Parameters:
-
(user¶str | None, default:None) –Name of Bazefield user. If is None api_key must be provided. By default None
-
(password¶str | None, default:None) –Bazefield user password. If is None api_key must be provided. By default None
-
(api_key¶str | None, default:DEFAULT_API_KEY) –API key used to connect. If is not None it will be preferred as user and password login. If None, user and password must be provided. By default None
Other Parameters:
-
conn_timeout(int) –Connection timeout in seconds. By default 30
-
request_timeout(int) –Request timeout in seconds. By default 300
-
max_retries(int) –Maximum number of retries in case of connection errors. By default 3
-
retry_wait_time(int) –Time to wait between retries in seconds. By default 1
Source code in echo_baze/baze.py
def __init__(
self,
user: str | None = None,
password: str | None = None,
api_key: str | None = DEFAULT_API_KEY,
**kwargs,
) -> None:
"""
Top level class used to connect to Bazefield. It will create the connection to Bazefield and then allow for all the APIs to be called by it's attributes.
By default no arguments needs to be provided as the package will use the default API key to connect to Bazefield, but it can be overridden. The following methods of login can be used:
- user and password: To use it, user and password must be provided and api_key must be set to None.
- api_key: To use it, pass the desired api_key or don't pass this argument to use the default one.
Parameters
----------
user : str | None, optional
Name of Bazefield user. If is None api_key must be provided. By default None
password : str | None, optional
Bazefield user password. If is None api_key must be provided. By default None
api_key : str | None, optional
API key used to connect. If is not None it will be preferred as user and password login. If None, user and password must be provided. By default None
Other Parameters
----------------
conn_timeout : int, optional
Connection timeout in seconds. By default 30
request_timeout : int, optional
Request timeout in seconds. By default 300
max_retries : int, optional
Maximum number of retries in case of connection errors. By default 3
retry_wait_time : int, optional
Time to wait between retries in seconds. By default 1
"""
# checking input
if (
not isinstance(user, str | type(None))
and not isinstance(password, str | type(None))
and not isinstance(api_key, str | type(None))
):
raise TypeError("user, password and api_key must be strings or None")
if api_key is None and (user is None or password is None):
raise ValueError("If api_key is None, user and password must be provided")
# creating connection properties to be used by the handler
conn_props = HttpConnProperties(
host=BASE_URL,
user=user,
password=password,
api_key=api_key if (not user and not password) else None,
conn_timeout=kwargs.get("conn_timeout", 30),
request_timeout=kwargs.get("request_timeout", 300),
)
# creating connection handler
self.conn = BazeHttpHandler(
connection_properties=conn_props,
max_retries=kwargs.get("max_retries", 3),
retry_wait_time=kwargs.get("retry_wait_time", 1),
)
# * subclasses
from .alarms import Alarms
from .allocations import Allocations
from .curves import Curves
from .devices import Devices
from .emails import Emails
from .jobs import Jobs
from .kpis import Kpis
from .links import Links
from .objects import Objects
from .points import Points
from .roles import Roles
from .users import Users
self.alarms = Alarms(baze=self)
self.allocations = Allocations(baze=self)
self.curves = Curves(baze=self)
self.devices = Devices(baze=self)
self.emails = Emails(baze=self)
self.jobs = Jobs(baze=self)
self.kpis = Kpis(baze=self)
self.links = Links(baze=self)
self.objects = Objects(baze=self)
self.points = Points(baze=self)
self.roles = Roles(baze=self)
self.users = Users(baze=self)