grafana-client 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: feef62d5dcc9495d04c3a012537f79488416e08a64d4ade27c43bc608adc055d
4
- data.tar.gz: 2d01176ce013313d5cf9b618f85000a66d84a9c4a4c766c563c1ab9d038a3f48
3
+ metadata.gz: 8f855fcd107829fe6a38608b160867dab591272da9fec63f8aba6b20b3cec35e
4
+ data.tar.gz: b1a62e82cb2ce97528be51e0a099fcfc835de974a9ec776fbce392e171120306
5
5
  SHA512:
6
- metadata.gz: '04993d0c515a02e0c91e24196d5e0c7a7616056715095290418436b29da3eb3824bb14c40b00b08cfadf259d85418b12d9085dff87b57d452e015710a4a550dd'
7
- data.tar.gz: e070532c25999ae481447b5d39a0db69ff44832046b119c641582d3d3f112e63f621838841f67d8a63645c7d6ffc9a6c90dd2c49306d0e79ff13054e665e1680
6
+ metadata.gz: 05bb6912d1040b15caf4631a667cbed87f299279fb93a6e72d4e49d7143c7e2393922dd8d5d3828106b2b5e24808a63cd841bd4ef9c7e535bb2def5e8ea7ca9d
7
+ data.tar.gz: a5766d1cc020f7d8fa24857cd167064501f3660440136828c610265ab32788bbb473cd504051aa7ebdcfe6df35ba0e19c263ea9ca082587365dab87d147b0e82
@@ -10,6 +10,8 @@ jobs:
10
10
  # due to https://github.com/actions/runner/issues/849, we need quotes for '3.0'
11
11
  ruby: [2.5, 2.6, 2.7, '3.0', head, jruby, jruby-head, truffleruby, truffleruby-head]
12
12
  runs-on: ${{ matrix.os }}
13
+ # Don't duplicate test runs for both push and PR for internal PRs
14
+ if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository }}
13
15
  steps:
14
16
  - name: "Checkout"
15
17
  uses: actions/checkout@v2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.1] - 2021-06-01
4
+
5
+ - Add Dashboard/Folder search capabilities
6
+
3
7
  ## [0.1.0] - 2021-05-21
4
8
 
5
9
  - Initial release
@@ -6,7 +6,7 @@ Dir[File.join(__dir__, 'modules', '*.rb')].sort.each { |file| require file }
6
6
  module Grafana
7
7
  class Client < Grafana::BaseClient
8
8
  VERSION = Grafana::CLIENT_VERSION
9
-
9
+
10
10
  class << self
11
11
  attr_accessor :api_key, :grafana_url
12
12
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Grafana
4
- CLIENT_VERSION = "0.1.0"
4
+ CLIENT_VERSION = "0.1.1"
5
5
  end
@@ -37,6 +37,34 @@ module Grafana
37
37
  post('/api/dashboards/db', req_body)
38
38
  end
39
39
 
40
+ def overwrite_dashboard(dashboard:, **options)
41
+ req_body = {
42
+ dashboard: dashboard,
43
+ message: options[:message],
44
+ folderId: options[:folder_id],
45
+ overwrite: true # Overwriting dashboard (if exists)
46
+ }
47
+
48
+ post('/api/dashboards/db', req_body)
49
+ end
50
+
51
+ def dashboard_search(**options)
52
+ options = options.slice(:query, :tag, :dashboard_ids, :folder_ids, :starred, :limit, :page)
53
+
54
+ options[:folderIds] = Array.wrap(options.delete(:folder_ids)) if options[:folder_ids].present?
55
+ options[:dashboardIds] = Array.wrap(options.delete(:dashboard_ids)) if options[:dashboard_ids].present?
56
+
57
+ options.delete(:starred) unless options[:starred].is_a?(Boolean)
58
+ options.delete(:limit) unless options[:limit].is_a?(Integer) && options[:limit] <= 5000
59
+ options.delete(:page) unless options[:page].is_a?(Integer)
60
+
61
+ options.merge({ type: 'dash-db' })
62
+
63
+ search_url = '/api/search'
64
+ search_url = "?#{URI.encode_www_form(options)}"
65
+ get(search_url)
66
+ end
67
+
40
68
  def dashboard(uid:)
41
69
  get("/api/dashboards/uid/#{uid}")
42
70
  end
@@ -1,6 +1,22 @@
1
1
  module Grafana
2
2
  module Modules
3
3
  module Folder
4
+ def folder_search(**options)
5
+ options = options.slice(:query, :tag, :dashboard_ids, :folder_ids, :starred, :limit, :page)
6
+
7
+ options[:folderIds] = Array.wrap(options.delete(:folder_ids)) if options[:folder_ids].present?
8
+ options[:dashboardIds] = Array.wrap(options.delete(:dashboard_ids)) if options[:dashboard_ids].present?
9
+
10
+ options.delete(:starred) unless options[:starred].is_a?(Boolean)
11
+ options.delete(:limit) unless options[:limit].is_a?(Integer) && options[:limit] <= 5000
12
+ options.delete(:page) unless options[:page].is_a?(Integer)
13
+
14
+ options.merge({ type: 'dash-folder' })
15
+
16
+ search_url = '/api/search'
17
+ search_url = "?#{URI.encode_www_form(options)}"
18
+ get(search_url)
19
+ end
4
20
  def folders
5
21
  get('/api/folders')
6
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grafana-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Tanous
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-28 00:00:00.000000000 Z
11
+ date: 2021-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday