Class: Grafana::Api::Reports

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

Defined Under Namespace

Classes: Dashboards, Images

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ Reports

Returns a new instance of Reports.



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

def initialize(connection)
  @connection = connection
end

Instance Method Details

#create(create_or_update_report:) ⇒ Object

Raises:

  • (ArgumentError)


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

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

  @connection.call(
    :POST,
    '/reports',
    type: Grafana::Api::Models::CreateReport200Response,
    auth: ['api_key', 'basic'],
    body: create_or_update_report
  )
end

#delete(id:) ⇒ Object

Raises:

  • (ArgumentError)


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

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

  @connection.call(
    :DELETE,
    '/reports/{id}'
      .gsub('{id}', ERB::Util.url_encode(id.to_s)),
    type: Grafana::Api::Models::SuccessResponseBody,
    auth: ['api_key', 'basic']
  )
end

#email(report_email:) ⇒ Object

Raises:

  • (ArgumentError)


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

def email(report_email:)
  raise ArgumentError, 'report_email is required' if report_email.nil?

  @connection.call(
    :POST,
    '/reports/email',
    type: Grafana::Api::Models::SuccessResponseBody,
    auth: ['api_key', 'basic'],
    body: report_email
  )
end

#get(id:) ⇒ Object

Raises:

  • (ArgumentError)


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

def get(id:)
  raise ArgumentError, 'id is required' if id.nil?

  @connection.call(
    :GET,
    '/reports/{id}'
      .gsub('{id}', ERB::Util.url_encode(id.to_s)),
    type: Grafana::Api::Models::Report,
    auth: ['api_key', 'basic']
  )
end

#listObject



57
58
59
60
61
62
63
64
# File 'lib/grafana-api/api/reports.rb', line 57

def list
  @connection.call(
    :GET,
    '/reports',
    type: [Grafana::Api::Models::Report],
    auth: ['api_key', 'basic']
  )
end

#render_csvs(dashboards: nil, title: nil) ⇒ Object



66
67
68
69
70
71
72
73
74
# File 'lib/grafana-api/api/reports.rb', line 66

def render_csvs(dashboards: nil, title: nil)
  @connection.call(
    :GET,
    '/reports/render/csvs',
    type: nil,
    auth: ['api_key', 'basic'],
    query: { 'dashboards' => dashboards, 'title' => title }
  )
end

#render_pdfs(dashboards: nil, orientation: nil, layout: nil, title: nil, scale_factor: nil, include_tables: nil) ⇒ Object



76
77
78
79
80
81
82
83
84
# File 'lib/grafana-api/api/reports.rb', line 76

def render_pdfs(dashboards: nil, orientation: nil, layout: nil, title: nil, scale_factor: nil, include_tables: nil)
  @connection.call(
    :GET,
    '/reports/render/pdfs',
    type: nil,
    auth: ['api_key', 'basic'],
    query: { 'dashboards' => dashboards, 'orientation' => orientation, 'layout' => layout, 'title' => title, 'scaleFactor' => scale_factor, 'includeTables' => include_tables }
  )
end

#settingsObject



86
87
88
89
90
91
92
93
# File 'lib/grafana-api/api/reports.rb', line 86

def settings
  @connection.call(
    :GET,
    '/reports/settings',
    type: Grafana::Api::Models::ReportSettings,
    auth: ['api_key', 'basic']
  )
end

#settings_post(report_settings:) ⇒ Object

Raises:

  • (ArgumentError)


95
96
97
98
99
100
101
102
103
104
105
# File 'lib/grafana-api/api/reports.rb', line 95

def settings_post(report_settings:)
  raise ArgumentError, 'report_settings is required' if report_settings.nil?

  @connection.call(
    :POST,
    '/reports/settings',
    type: Grafana::Api::Models::SuccessResponseBody,
    auth: ['api_key', 'basic'],
    body: report_settings
  )
end

#test_email(create_or_update_report:) ⇒ Object

Raises:

  • (ArgumentError)


107
108
109
110
111
112
113
114
115
116
117
# File 'lib/grafana-api/api/reports.rb', line 107

def test_email(create_or_update_report:)
  raise ArgumentError, 'create_or_update_report is required' if create_or_update_report.nil?

  @connection.call(
    :POST,
    '/reports/test-email',
    type: Grafana::Api::Models::SuccessResponseBody,
    auth: ['api_key', 'basic'],
    body: create_or_update_report
  )
end

#update(id:, create_or_update_report:) ⇒ Object

Raises:

  • (ArgumentError)


119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/grafana-api/api/reports.rb', line 119

def update(id:, create_or_update_report:)
  raise ArgumentError, 'id is required' if id.nil?
  raise ArgumentError, 'create_or_update_report is required' if create_or_update_report.nil?

  @connection.call(
    :PUT,
    '/reports/{id}'
      .gsub('{id}', ERB::Util.url_encode(id.to_s)),
    type: Grafana::Api::Models::SuccessResponseBody,
    auth: ['api_key', 'basic'],
    body: create_or_update_report
  )
end