class Dogapi::V1::DashboardService
Dashboard API
Constants
- API_VERSION
- RESOURCE_NAME
Public Instance Methods
Create new dashboard
Required arguments: :title => String: Title of the dashboard :widgets => JSON: List of widgets to display on the dashboard :layout_type => String: Layout type of the dashboard.
Allowed values: 'ordered' or 'free'
Optional arguments: :description => String: Description of the dashboard :is_read_only => Boolean: Whether this dashboard is read-only.
If True, only the author and admins can make changes to it.
:notify_list => JSON: List of handles of users to notify when changes are made to this dashboard
e.g. '["user1@domain.com", "user2@domain.com"]'
:template_variables => JSON: List of template variables for this dashboard.
e.g. [{"name": "host", "prefix": "host", "default": "my-host"}]
:template_variable_presets => JSON: List of template variables saved views
e.g. { "name": "my_template_variable_preset", "template_variables": [{"name": "host", "prefix": "host", "default": "my-host"}] }
# File lib/dogapi/v1/dashboard.rb 34 def create_board(title, widgets, layout_type, options) 35 # Required arguments 36 body = { 37 title: title, 38 widgets: widgets, 39 layout_type: layout_type 40 } 41 # Optional arguments 42 body[:description] = options[:description] if options[:description] 43 body[:is_read_only] = options[:is_read_only] if options[:is_read_only] 44 body[:notify_list] = options[:notify_list] if options[:notify_list] 45 body[:template_variables] = options[:template_variables] if options[:template_variables] 46 body[:template_variable_presets] = options[:template_variable_presets] if options[:template_variable_presets] 47 48 request(Net::HTTP::Post, "/api/#{API_VERSION}/#{RESOURCE_NAME}", nil, body, true) 49 end
Delete the given dashboard
Required argument: :dashboard_id => String: ID of the dashboard
# File lib/dogapi/v1/dashboard.rb 106 def delete_board(dashboard_id) 107 request(Net::HTTP::Delete, "/api/#{API_VERSION}/#{RESOURCE_NAME}/#{dashboard_id}", nil, nil, false) 108 end
Fetch all custom dashboards
# File lib/dogapi/v1/dashboard.rb 98 def get_all_boards 99 request(Net::HTTP::Get, "/api/#{API_VERSION}/#{RESOURCE_NAME}", nil, nil, false) 100 end
Fetch the given dashboard
Required argument: :dashboard_id => String: ID of the dashboard
# File lib/dogapi/v1/dashboard.rb 93 def get_board(dashboard_id) 94 request(Net::HTTP::Get, "/api/#{API_VERSION}/#{RESOURCE_NAME}/#{dashboard_id}", nil, nil, false) 95 end
Update a dashboard
Required arguments: :dashboard_id => String: ID of the dashboard :title => String: Title of the dashboard :widgets => JSON: List of widgets to display on the dashboard :layout_type => String: Layout type of the dashboard.
Allowed values: 'ordered' or 'free'
Optional arguments: :description => String: Description of the dashboard :is_read_only => Boolean: Whether this dashboard is read-only.
If True, only the author and admins can make changes to it.
:notify_list => JSON: List of handles of users to notify when changes are made to this dashboard
e.g. '["user1@domain.com", "user2@domain.com"]'
:template_variables => JSON: List of template variables for this dashboard.
e.g. [{"name": "host", "prefix": "host", "default": "my-host"}]
:template_variable_presets => JSON: List of template variables saved views
e.g. { "name": "my_template_variable_preset", "template_variables": [{"name": "host", "prefix": "host", "default": "my-host"}] }
# File lib/dogapi/v1/dashboard.rb 72 def update_board(dashboard_id, title, widgets, layout_type, options) 73 # Required arguments 74 body = { 75 title: title, 76 widgets: widgets, 77 layout_type: layout_type 78 } 79 # Optional arguments 80 body[:description] = options[:description] if options[:description] 81 body[:is_read_only] = options[:is_read_only] if options[:is_read_only] 82 body[:notify_list] = options[:notify_list] if options[:notify_list] 83 body[:template_variables] = options[:template_variables] if options[:template_variables] 84 body[:template_variable_presets] = options[:template_variable_presets] if options[:template_variable_presets] 85 86 request(Net::HTTP::Put, "/api/#{API_VERSION}/#{RESOURCE_NAME}/#{dashboard_id}", nil, body, true) 87 end