Class: Grafana::Api::QueryHistory

Inherits:
Object
  • Object
show all
Defined in:
lib/grafana-api/api/query_history.rb

Defined Under Namespace

Classes: Star

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ QueryHistory

Returns a new instance of QueryHistory.



5
6
7
# File 'lib/grafana-api/api/query_history.rb', line 5

def initialize(connection)
  @connection = connection
end

Instance Method Details

#create(create_query_in_query_history_command:) ⇒ Object

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
17
18
19
# File 'lib/grafana-api/api/query_history.rb', line 9

def create(create_query_in_query_history_command:)
  raise ArgumentError, 'create_query_in_query_history_command is required' if create_query_in_query_history_command.nil?

  @connection.call(
    :POST,
    '/query-history',
    type: Grafana::Api::Models::QueryHistoryResponse,
    auth: ['api_key', 'basic'],
    body: create_query_in_query_history_command
  )
end

#delete(query_history_uid:) ⇒ Object

Raises:

  • (ArgumentError)


21
22
23
24
25
26
27
28
29
30
31
# File 'lib/grafana-api/api/query_history.rb', line 21

def delete(query_history_uid:)
  raise ArgumentError, 'query_history_uid is required' if query_history_uid.nil?

  @connection.call(
    :DELETE,
    '/query-history/{query_history_uid}'
      .gsub('{query_history_uid}', ERB::Util.url_encode(query_history_uid.to_s)),
    type: Grafana::Api::Models::QueryHistoryDeleteQueryResponse,
    auth: ['api_key', 'basic']
  )
end

#list(datasource_uid: nil, search_string: nil, only_starred: nil, sort: nil, page: nil, limit: nil, from: nil, to: nil) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/grafana-api/api/query_history.rb', line 33

def list(datasource_uid: nil, search_string: nil, only_starred: nil, sort: nil, page: nil, limit: nil, from: nil, to: nil)
  @connection.call(
    :GET,
    '/query-history',
    type: Grafana::Api::Models::QueryHistorySearchResponse,
    auth: ['api_key', 'basic'],
    query: { 'datasourceUid' => datasource_uid, 'searchString' => search_string, 'onlyStarred' => only_starred, 'sort' => sort, 'page' => page, 'limit' => limit, 'from' => from, 'to' => to }
  )
end

#partial_update(query_history_uid:, patch_query_comment_in_query_history_command:) ⇒ Object

Raises:

  • (ArgumentError)


43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/grafana-api/api/query_history.rb', line 43

def partial_update(query_history_uid:, patch_query_comment_in_query_history_command:)
  raise ArgumentError, 'query_history_uid is required' if query_history_uid.nil?
  raise ArgumentError, 'patch_query_comment_in_query_history_command is required' if patch_query_comment_in_query_history_command.nil?

  @connection.call(
    :PATCH,
    '/query-history/{query_history_uid}'
      .gsub('{query_history_uid}', ERB::Util.url_encode(query_history_uid.to_s)),
    type: Grafana::Api::Models::QueryHistoryResponse,
    auth: ['api_key', 'basic'],
    body: patch_query_comment_in_query_history_command
  )
end