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

Feature/datasource uid #300

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/puppet/provider/grafana_datasource/grafana.rb
Expand Up @@ -19,6 +19,10 @@ def grafana_api_path
resource[:grafana_api_path]
end

def grafana_api_path
joernott marked this conversation as resolved.
Show resolved Hide resolved
resource[:uid]
end

def fetch_organizations
response = send_request('GET', format('%s/orgs', resource[:grafana_api_path]))
raise format('Fail to retrieve organizations (HTTP response: %s/%s)', response.code, response.body) if response.code != '200'
Expand Down Expand Up @@ -66,6 +70,7 @@ def datasources
{
id: datasource['id'],
name: datasource['name'],
uid: datasource['uid'],
url: datasource['url'],
type: datasource['type'],
user: datasource['user'],
Expand Down Expand Up @@ -219,6 +224,7 @@ def save_datasource

data = {
name: resource[:name],
uid: resource[:uid],
type: resource[:type],
url: resource[:url],
access: resource[:access_mode],
Expand Down
4 changes: 4 additions & 0 deletions lib/puppet/type/grafana_datasource.rb
Expand Up @@ -11,6 +11,10 @@
desc 'The name of the datasource.'
end

newparam(:uid) do
joernott marked this conversation as resolved.
Show resolved Hide resolved
desc 'The uid of the datasource.'
end

newparam(:grafana_api_path) do
desc 'The absolute path to the API endpoint'
defaultto '/api'
Expand Down