Skip to content

Bleemeo Python Python 3.8 at leastGitHub License

Python library for interacting with the Bleemeo API

Requirements

  • Python3.8 or later
  • An account on Bleemeo

Installation

Take a look at venv. This tool provides isolated Python environments, which are more practical than installing packages system-wide.

After you’ve created and activated a virtual environment, run the command:

python -m pip install --upgrade bleemeo

Documentation

The Python library is documented using docstring in the source code.

Some examples of library usage can be found in examples.

Basic usage

Listing the first 10 agents of your account:

frombleemeoimportClient, Resource, APIErrordeflist_agents():
withClient(load_from_env=True) asclient:
try:
resp_page=client.get_page(Resource.AGENT, page=1, page_size=10,
params={"active": True, "fields": "id,fqdn,display_name"})
foragentinresp_page.json()["results"]:
print(f"* Agent {agent['display_name']} (fqdn = {agent['fqdn']}, id = {agent['id']})")
exceptAPIErrorase:
print(f"API error: {e}:\n{e.response.text}")
if__name__=='__main__':
list_agents()

Save this file as list_agents.py.

Run it with:

BLEEMEO_USER=user-email@domain.com BLEEMEO_PASSWORD=password python3 list_agents.py

More examples can be found in examples

To run an example from a clone of this repository, run the following:

BLEEMEO_USER=user-email@domain.com BLEEMEO_PASSWORD=password python3 examples/list_metrics.py

Environment

At least the following options should be configured (as environment variables or with options):

  • Credentials OR initial refresh token
  • All other configuration options are optional and could be omitted

Ways to provide those options are referenced in the Configuration section.

Configuration

For environment variables to be taken into account, the parameter load_from_env of the Client constructor must be set to True.

PropertyConstructor parameter(s)Env variable(s)Default values
Credentialsusername & passwordBLEEMEO_USER & BLEEMEO_PASSWORDNone. This option is required (unless initial refresh token is used)
Bleemeo account headeraccount_idBLEEMEO_ACCOUNT_IDThe first account associated with used credentials.
OAuth client ID/secretoauth_client_id & oauth_client_secretBLEEMEO_OAUTH_CLIENT_ID & BLEEMEO_OAUTH_CLIENT_SECRETThe default SDK OAuth client ID
API URLapi_urlBLEEMEO_API_URLhttps://api.bleemeo.com
Initial refresh tokenoauth_initial_refresh_tokenBLEEMEO_OAUTH_INITIAL_REFRESH_TOKENNone. This is an alternative to username & password credentials.
Custom headerscustom_headers-{"User-Agent": "Bleemeo Python Client"}
Throttle max auto retry delaythrottle_max_auto_retry_delay-1 minute.

About

Bleemeo Python SDK

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

4 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages