Skip to content

Table of Contents

folder

Folder Objects

class Folder()

The class includes all necessary methods to access the Grafana folder API endpoints

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_folders

def get_folders() -> list

The method includes a functionality to extract all folders inside the organization

Required Permissions: Action: folders:read Scope: folders:*

Raises:

  • Exception - Unspecified error by executing the API call

Returns:

  • api_call list - Returns all folders

get_folder_by_uid

def get_folder_by_uid(uid: str) -> dict

The method includes a functionality to extract all folder information specified by the uid of the folder

Arguments:

  • uid str - Specify the uid of the folder

Required Permissions: - Action - folders:read - Scope - folders:*

Raises:

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

Returns:

  • api_call dict - Returns a folder

get_folder_by_id

def get_folder_by_id(id: int) -> dict

The method includes a functionality to extract all folder information specified by the id of the folder

Arguments:

  • id int - Specify the id of the folder

Required Permissions: - Action - folders:read - Scope - folders:*

Raises:

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

Returns:

  • api_call dict - Returns a folder

create_folder

def create_folder(title: str, uid: str = None, parent_uid: str = None) -> dict

The method includes a functionality to create a new folder inside the organization specified by the defined title and the optional uid

Arguments:

  • title str - Specify the title of the folder
  • uid str - Specify the uid of the folder (default None)
  • parent_uid str - Specify the parent_uid of the folder (default None)

Required Permissions: - Action - folders:create, folders:write - Scope - folders:*

Raises:

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

Returns:

  • api_call dict - Returns a newly created folder

update_folder

def update_folder(title: str,
                  uid: str,
                  version: int = 0,
                  overwrite: bool = False) -> dict

The method includes a functionality to update a folder information inside the organization specified by the uid, the title, the version of the folder or if folder information be overwritten

Arguments:

  • title str - Specify the title of the folder
  • uid str - Specify the uid of the folder
  • version int - Specify the version of the folder (default 0)
  • overwrite bool - Should the already existing folder information be overwritten (default False)

Required Permissions: - Action - folders:write - Scope - folders:*

Raises:

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

Returns:

  • api_call dict - Returns an updated folder

move_folder

def move_folder(uid: str, parent_uid: str = None)

The method includes a functionality to move a folder inside the organization specified by the defined uid. This feature is only relevant if nested folders are enabled

Arguments:

  • uid str - Specify the uid of the folder
  • parent_uid str - Specify the parent_uid of the folder. If the value is None, then the folder is moved under the root (default None)

Required Permissions: - Action - folders:create, folders:write - Scope - folders:*, folders:uid:

Raises:

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

Returns:

  • api_call dict - Returns the moved folder

delete_folder

def delete_folder(uid: str)

The method includes a functionality to delete a folder inside the organization specified by the defined uid

Arguments:

  • uid str - Specify the uid of the folder

Required Permissions: - Action - folders:delete - Scope - folders:*

Raises:

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

Returns:

None

get_folder_permissions

def get_folder_permissions(uid: str) -> list

The method includes a functionality to extract the folder permissions inside the organization specified by the defined uid

Arguments:

  • uid str - Specify the uid of the folder

Required Permissions: - Action - folders.permissions:read - Scope - folders:*

Raises:

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

Returns:

  • api_call list - Returns a list of folder permissions

update_folder_permissions

def update_folder_permissions(uid: str, permission_json: dict)

The method includes a functionality to update the folder permissions based on the specified uid and the permission json document

Arguments:

  • uid str - Specify the uid of the folder
  • permission_json dict - Specify the inserted permissions as dict

Required Permissions: - Action - folders.permissions:write - Scope - folders:*

Raises:

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

Returns:

None

get_folder_id_by_dashboard_path

def get_folder_id_by_dashboard_path(dashboard_path: str) -> int

The method includes a functionality to extract the folder id specified inside model dashboard path

Arguments:

  • dashboard_path str - Specify the dashboard path

Raises:

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

Returns:

  • folder_id int - Returns the folder id

get_all_folder_ids_and_names

def get_all_folder_ids_and_names() -> list

The method extract all folder id and names inside the complete organisation

Returns:

  • folders list - Returns a list of dicts with folder ids and the corresponding names