Module: Grafana::Modules::Folder
- Included in:
- Folders
- Defined in:
- lib/grafana/modules/folder.rb
Instance Method Summary collapse
- #create_folder(title:, uid: nil) ⇒ Object
- #delete_folder(uid:) ⇒ Object
- #folder(uid:) ⇒ Object
- #folder_search(**options) ⇒ Object
- #folders ⇒ Object
- #update_folder(uid:, **options) ⇒ Object
Instance Method Details
#create_folder(title:, uid: nil) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/grafana/modules/folder.rb', line 28 def create_folder(title:, uid: nil) req_body = { title: title } req_body.merge(uid: uid) if uid.present? post('/api/folders', req_body) end |
#delete_folder(uid:) ⇒ Object
46 47 48 |
# File 'lib/grafana/modules/folder.rb', line 46 def delete_folder(uid:) delete("/api/folders#{uid}") end |
#folder(uid:) ⇒ Object
24 25 26 |
# File 'lib/grafana/modules/folder.rb', line 24 def folder(uid:) get("/api/folders/#{uid}") end |
#folder_search(**options) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/grafana/modules/folder.rb', line 4 def folder_search(**) = .slice(:query, :tag, :dashboard_ids, :folder_ids, :starred, :limit, :page) [:folderIds] = Array.wrap(.delete(:folder_ids)) if [:folder_ids].present? [:dashboardIds] = Array.wrap(.delete(:dashboard_ids)) if [:dashboard_ids].present? .delete(:starred) unless [:starred].is_a?(Boolean) .delete(:limit) unless [:limit].is_a?(Integer) && [:limit] <= 5000 .delete(:page) unless [:page].is_a?(Integer) .merge({ type: 'dash-folder' }) search_url = '/api/search' search_url = "?#{URI.encode_www_form()}" get(search_url) end |
#folders ⇒ Object
20 21 22 |
# File 'lib/grafana/modules/folder.rb', line 20 def folders get('/api/folders') end |
#update_folder(uid:, **options) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/grafana/modules/folder.rb', line 38 def update_folder(uid:, **) # Drop any keys that are not valid for the request = .slice(:title, :new_uid, :version, :overwrite) [:uid] = .delete(:new_uid) if .key(:new_uid) post("/api/folders/#{uid}", ) end |