Class: Grafana::Api::Datasources::Name

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

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ Name

Returns a new instance of Name.



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

def initialize(connection)
  @connection = connection
end

Instance Method Details

#delete(name:) ⇒ Object

Raises:

  • (ArgumentError)


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

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

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

#get(name:) ⇒ Object

Raises:

  • (ArgumentError)


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

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

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