Class: DogapiDemo::V1::DashService

Inherits:
APIService show all
Defined in:
lib/dogapi-demo/v1/dash.rb

Constant Summary collapse

API_VERSION =
"v1"

Instance Method Summary collapse

Methods inherited from APIService

#connect, #initialize, #request, #suppress_error_if_silent

Constructor Details

This class inherits a constructor from DogapiDemo::APIService

Instance Method Details

#create_dashboard(title, description, graphs, template_variables = nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/dogapi-demo/v1/dash.rb', line 10

def create_dashboard(title, description, graphs, template_variables = nil)

  begin
    params = {
      :api_key => @api_key,
      :application_key => @application_key
    }

    body = {
      :title => title,
      :description => description,
      :graphs => graphs,
      :template_variables => (template_variables or [])
    }

    request(Net::HTTP::Post, "/api/#{API_VERSION}/dash", params, body, true)
  rescue Exception => e
    suppress_error_if_silent e
  end
end

#delete_dashboard(dash_id) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/dogapi-demo/v1/dash.rb', line 78

def delete_dashboard(dash_id)
  begin
    params = {
      :api_key => @api_key,
      :application_key => @application_key
    }

    request(Net::HTTP::Delete, "/api/#{API_VERSION}/dash/#{dash_id}", params, nil, false)
  rescue Exception => e
    suppress_error_if_silent e
  end
end

#get_dashboard(dash_id) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/dogapi-demo/v1/dash.rb', line 52

def get_dashboard(dash_id)
  begin
    params = {
      :api_key => @api_key,
      :application_key => @application_key
    }

    request(Net::HTTP::Get, "/api/#{API_VERSION}/dash/#{dash_id}", params, nil, false)
  rescue Exception => e
    suppress_error_if_silent e
  end
end

#get_dashboardsObject



65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/dogapi-demo/v1/dash.rb', line 65

def get_dashboards
  begin
    params = {
      :api_key => @api_key,
      :application_key => @application_key
    }

    request(Net::HTTP::Get, "/api/#{API_VERSION}/dash", params, nil, false)
  rescue Exception => e
    suppress_error_if_silent e
  end
end

#update_dashboard(dash_id, title, description, graphs, template_variables = nil) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/dogapi-demo/v1/dash.rb', line 31

def update_dashboard(dash_id, title, description, graphs, template_variables=nil)

  begin
    params = {
      :api_key => @api_key,
      :application_key => @application_key
    }

    body = {
      :title => title,
      :description => description,
      :graphs => graphs,
      :template_variables => (template_variables or [])
    }

    request(Net::HTTP::Put, "/api/#{API_VERSION}/dash/#{dash_id}", params, body, true)
  rescue Exception => e
    suppress_error_if_silent e
  end
end