Skip to content

Table of Contents

admin

Admin Objects

class Admin()

The class includes all necessary methods to access the Grafana admin API endpoints. Be aware that all functionalities inside the class only working with basic authentication (username and password) and that the authenticated user is a Grafana Admin.

HINT: Note Grafana Enterprise API need required permissions if fine-grained access control is enabled

Arguments:

  • grafana_api_model APIModel - Inject a Grafana API model object that includes all necessary values and information

Attributes:

  • grafana_api_model APIModel - This is where we store the grafana_api_model

get_settings

def get_settings() -> dict

The method includes a functionality to get the settings

Raises:

  • Exception - Unspecified error by executing the API call

Returns:

  • api_call dict - Returns the corresponding settings

update_settings

def update_settings(updates: dict = None, removals: dict = None)

The method includes a functionality to update the settings. Be aware that the functionality is a Grafana v8.0+ feature and you can find detailed information about the dict values here: https://grafana.com/docs/grafana/latest/developers/http_api/admin/update-settings

Arguments:

  • updates dict - Specify the updates object
  • removals dict - Specify the removals object

Raises:

  • Exception - Unspecified error by executing the API call

Returns:

None

get_stats

def get_stats() -> dict

The method includes a functionality to get the admin statistics

Raises:

  • Exception - Unspecified error by executing the API call

Returns:

  • api_call dict - Returns the corresponding statistics

get_preview_report

def get_preview_report() -> dict

The method includes a functionality to get a preview report

Raises:

  • Exception - Unspecified error by executing the API call

Returns:

  • api_call dict - Returns the preview report

create_global_user

def create_global_user(user: GlobalUser) -> int

The method includes a functionality to create a global user

Arguments:

  • user GlobalUser - Specify the global user object

Raises:

  • ValueError - Missed specifying a necessary value
  • Exception - Unspecified error by executing the API call

Returns:

  • api_call int - Returns the corresponding user id

update_user_password

def update_user_password(id: int, password: str)

The method includes a functionality to update the global user password

Arguments:

  • id int - Specify the user id
  • password str - Specify the user new password

Raises:

  • ValueError - Missed specifying a necessary value
  • Exception - Unspecified error by executing the API call

Returns:

None

update_user_permissions

def update_user_permissions(id: int, is_grafana_admin: bool = None)

The method includes a functionality to update the global user permissions

Arguments:

  • id int - Specify the user id
  • is_grafana_admin bool - Specify if the user is admin or not

Raises:

  • ValueError - Missed specifying a necessary value
  • Exception - Unspecified error by executing the API call

Returns:

None

delete_global_user

def delete_global_user(id: int)

The method includes a functionality to delete a global user

Arguments:

  • id int - Specify the user id

Raises:

  • ValueError - Missed specifying a necessary value
  • Exception - Unspecified error by executing the API call

Returns:

None

pause_all_alerts

def pause_all_alerts()

The method includes a functionality to pause all alerts

Raises:

  • ValueError - Missed specifying a necessary value
  • Exception - Unspecified error by executing the API call

Returns:

None

unpause_all_alerts

def unpause_all_alerts()

The method includes a functionality to unpause all alerts

Raises:

  • ValueError - Missed specifying a necessary value
  • Exception - Unspecified error by executing the API call

Returns:

None

get_user_auth_token

def get_user_auth_token(id: int) -> list

The method includes a functionality to get the corresponding user auth token

Arguments:

  • id int - Specify the user id

Raises:

  • ValueError - Missed specifying a necessary value
  • Exception - Unspecified error by executing the API call

Returns:

  • api_call list - Returns the corresponding user auth tokens

revoke_user_auth_token

def revoke_user_auth_token(id: int, auth_token_id: int)

The method includes a functionality to get the corresponding user auth token

Arguments:

  • id int - Specify the user id
  • auth_token_id int - Specify the auth token id

Raises:

  • ValueError - Missed specifying a necessary value
  • Exception - Unspecified error by executing the API call

Returns:

None

logout_user

def logout_user(id: int)

The method includes a functionality to log out the corresponding user

Arguments:

  • id int - Specify the user id

Raises:

  • ValueError - Missed specifying a necessary value
  • Exception - Unspecified error by executing the API call

Returns:

None

reload_dashboards_provisioning_configuration

def reload_dashboards_provisioning_configuration()

The method includes a functionality to reload the dashboards provisioning configuration

Raises:

  • Exception - Unspecified error by executing the API call

Returns:

None

reload_datasources_provisioning_configuration

def reload_datasources_provisioning_configuration()

The method includes a functionality to reload the datasources provisioning configuration

Raises:

  • Exception - Unspecified error by executing the API call

Returns:

None

reload_plugins_provisioning_configuration

def reload_plugins_provisioning_configuration()

The method includes a functionality to reload the plugins provisioning configuration

Raises:

  • Exception - Unspecified error by executing the API call

Returns:

None

reload_notifications_provisioning_configuration

def reload_notifications_provisioning_configuration()

The method includes a functionality to reload the notifications provisioning configuration

Raises:

  • Exception - Unspecified error by executing the API call

Returns:

None

reload_access_controls_provisioning_configuration

def reload_access_controls_provisioning_configuration()

The method includes a functionality to reload the access-controls provisioning configuration

Raises:

  • Exception - Unspecified error by executing the API call

Returns:

None

reload_ldap_configuration

def reload_ldap_configuration()

The method includes a functionality to reload the ldap configuration

Raises:

  • Exception - Unspecified error by executing the API call

Returns:

None

rotate_data_encryption_keys

def rotate_data_encryption_keys()

The method includes a functionality to rotate the data encryption keys

Raises:

  • Exception - Unspecified error by executing the API call

Returns:

None