Table of Contents
library
Library Objects
class Library()
The class includes all necessary methods to access the Grafana library API endpoints
Arguments:
grafana_api_modelAPIModel - Inject a Grafana API model object that includes all necessary values and information
Attributes:
grafana_api_modelAPIModel - This is where we store the grafana_api_model
get_all_library_elements
def get_all_library_elements(
results_per_page: int = 100,
pages: int = 1,
search_string: str = None,
kind: int = 1,
sort_direction: SortDirection = SortDirection.DESC,
types_filter: str = None,
exclude_uid: str = None,
folder_filter_ids: str = None) -> dict
The method includes a functionality to get a list of all library elements the authenticated user has permission to view. Use the perPage query parameter to control the maximum number of library elements returned, The default limit is 100. You can also use the page query parameter to fetch library elements from any page other than the first one
Arguments:
results_per_pageint - Specify the results_per_page as integer (default 100)pagesint - Specify the pages as integer (default 1)search_stringstr - Specify the search string (default None)kindint - Specify the kind of element to search for. Use 1 for library panels or 2 for library variables (default 1)sort_directionSortDirection - Specify the sort order of elements. Use alpha-asc for ascending and alpha-desc for descending sort order (default alpha-desc)types_filterstr - Specify a comma separated list of types to filter the elements by (default None)exclude_uidstr - Specify the element uid to exclude from search results (default None)folder_filter_idsstr - Specify a comma separated list of folder ID(s) to filter the elements by (default None)
Raises:
Exception- Unspecified error by executing the API call
Returns:
api_calldict - Returns the library elements
get_library_element_by_uid
def get_library_element_by_uid(uid: str) -> dict
The method includes a functionality to get a library element with the given uid
Arguments:
uidstr - Specify the uid of the library element
Raises:
ValueError- Missed specifying a necessary valueException- Unspecified error by executing the API call
Returns:
api_calldict - Returns the corresponding library element
get_library_element_by_name
def get_library_element_by_name(name: str) -> dict
The method includes a functionality to get a library element with the given name
Arguments:
namestr - Specify the name of the library element
Raises:
ValueError- Missed specifying a necessary valueException- Unspecified error by executing the API call
Returns:
api_calldict - Returns the corresponding library element
get_library_element_connections
def get_library_element_connections(uid: str) -> dict
The method includes a functionality to get a list of connections for a library element based on the specified uid
Arguments:
uidstr - Specify the uid of the library element
Raises:
ValueError- Missed specifying a necessary valueException- Unspecified error by executing the API call
Returns:
api_calldict - Returns the corresponding list of connections
create_library_element
def create_library_element(folder_id: int,
model: dict,
kind: int = 1,
folder_uid: str = None,
name: str = None,
uid: str = None) -> dict
The method includes a functionality to create a library element based on the specified folder id and model
Arguments:
folder_idint - Specify the folder where the library element is stored. It is deprecated since Grafana v9modeldict - Specify the JSON model for the library elementkindint - Specify the kind of element to search for. Use 1 for library panels or 2 for library variables (default 1)folder_uidstr - Specify the uid of the folder where the library element is stored. Specify an empty string when it is general folder (default None)namestr - Specify the name of the library element (default None)uidstr - Specify the uid of the library element (default None)
Raises:
ValueError- Missed specifying a necessary valueException- Unspecified error by executing the API call
Returns:
api_calldict - Returns the newly created library element
update_library_element
def update_library_element(uid: str,
folder_id: int,
folder_uid: str,
name: str,
model: dict,
version: int,
kind: int = 1) -> dict
The method includes a functionality to update a library element
Arguments:
uidstr - Specify the uid of the library elementfolder_idint - Specify the folder where the library element is stored. It is deprecated since Grafana v9folder_uidstr - Specify the uid of the folder where the library element is stored. Specify an empty string when it is general foldernamestr - Specify the name of the library elementmodeldict - Specify the JSON model for the library elementversionint - Specify the version for the library elementkindint - Specify the kind of element to search for. Use 1 for library panels or 2 for library variables (default 1)
Raises:
ValueError- Missed specifying a necessary valueException- Unspecified error by executing the API call
Returns:
api_calldict - Returns the updated library element
delete_library_element
def delete_library_element(uid: str)
The method includes a functionality to delete a library element specified by the uid
Arguments:
uidstr - Specify the uid of the library element
Raises:
ValueError- Missed specifying a necessary valueException- Unspecified error by executing the API call
Returns:
None