Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dashboard read_only option #135

Merged
merged 2 commits into from
Jan 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/dogapi/facade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,13 @@ def detach_tags(host_id, source=nil)
#

# Create a dashboard.
def create_dashboard(title, description, graphs, template_variables=nil)
@dash_service.create_dashboard(title, description, graphs, template_variables)
def create_dashboard(title, description, graphs, template_variables = nil, read_only = false)
@dash_service.create_dashboard(title, description, graphs, template_variables, read_only)
end

# Update a dashboard.
def update_dashboard(dash_id, title, description, graphs, template_variables=nil)
@dash_service.update_dashboard(dash_id, title, description, graphs, template_variables)
def update_dashboard(dash_id, title, description, graphs, template_variables = nil, read_only = false)
@dash_service.update_dashboard(dash_id, title, description, graphs, template_variables, read_only)
end

# Fetch the given dashboard.
Expand Down
10 changes: 6 additions & 4 deletions lib/dogapi/v1/dash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,25 @@ class DashService < Dogapi::APIService

API_VERSION = 'v1'

def create_dashboard(title, description, graphs, template_variables = nil)
def create_dashboard(title, description, graphs, template_variables = nil, read_only = false)
body = {
:title => title,
:description => description,
:graphs => graphs,
:template_variables => (template_variables or [])
:template_variables => (template_variables or []),
:read_only => read_only
}

request(Net::HTTP::Post, "/api/#{API_VERSION}/dash", nil, body, true)
end

def update_dashboard(dash_id, title, description, graphs, template_variables=nil)
def update_dashboard(dash_id, title, description, graphs, template_variables = nil, read_only = false)
body = {
:title => title,
:description => description,
:graphs => graphs,
:template_variables => (template_variables or [])
:template_variables => (template_variables or []),
:read_only => read_only
}

request(Net::HTTP::Put, "/api/#{API_VERSION}/dash/#{dash_id}", nil, body, true)
Expand Down
4 changes: 3 additions & 1 deletion spec/integration/dash_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
'prefix' => 'host',
'default' => 'host:my-host'
}].freeze
READ_ONLY = false

DASH_BODY = {
title: TITLE,
description: DESCRIPTION,
graphs: GRAPHS,
template_variables: TEMPLATE_VARIABLES
template_variables: TEMPLATE_VARIABLES,
read_only: READ_ONLY
}.freeze
DASH_ARGS = DASH_BODY.values

Expand Down