Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
f824004e
Commit
f824004e
authored
Mar 08, 2016
by
Carl Bergquist
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4279 from utkarshcmu/ds-api
Implemented GetDataSourceByName API
parents
453eebba
1a39d93b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
pkg/api/api.go
+4
-0
pkg/api/datasources.go
+32
-0
No files found.
pkg/api/api.go
View file @
f824004e
...
@@ -174,6 +174,10 @@ func Register(r *macaron.Macaron) {
...
@@ -174,6 +174,10 @@ func Register(r *macaron.Macaron) {
r
.
Get
(
"/plugins"
,
GetDataSourcePlugins
)
r
.
Get
(
"/plugins"
,
GetDataSourcePlugins
)
},
reqOrgAdmin
)
},
reqOrgAdmin
)
r
.
Group
(
"/datasources/name/:name"
,
func
()
{
r
.
Get
(
"/"
,
wrap
(
GetDataSourceByName
))
},
reqOrgAdmin
)
r
.
Get
(
"/frontend/settings/"
,
GetFrontendSettings
)
r
.
Get
(
"/frontend/settings/"
,
GetFrontendSettings
)
r
.
Any
(
"/datasources/proxy/:id/*"
,
reqSignedIn
,
ProxyDataSourceRequest
)
r
.
Any
(
"/datasources/proxy/:id/*"
,
reqSignedIn
,
ProxyDataSourceRequest
)
r
.
Any
(
"/datasources/proxy/:id"
,
reqSignedIn
,
ProxyDataSourceRequest
)
r
.
Any
(
"/datasources/proxy/:id"
,
reqSignedIn
,
ProxyDataSourceRequest
)
...
...
pkg/api/datasources.go
View file @
f824004e
...
@@ -132,3 +132,35 @@ func GetDataSourcePlugins(c *middleware.Context) {
...
@@ -132,3 +132,35 @@ func GetDataSourcePlugins(c *middleware.Context) {
c
.
JSON
(
200
,
dsList
)
c
.
JSON
(
200
,
dsList
)
}
}
}
}
// Get /api/datasources/name/:name
func
GetDataSourceByName
(
c
*
middleware
.
Context
)
Response
{
query
:=
m
.
GetDataSourceByNameQuery
{
Name
:
c
.
Params
(
":name"
),
OrgId
:
c
.
OrgId
}
if
err
:=
bus
.
Dispatch
(
&
query
);
err
!=
nil
{
if
err
==
m
.
ErrDataSourceNotFound
{
return
ApiError
(
404
,
"Data source not found"
,
nil
)
}
return
ApiError
(
500
,
"Failed to query datasources"
,
err
)
}
ds
:=
query
.
Result
return
Json
(
200
,
&
dtos
.
DataSource
{
Id
:
ds
.
Id
,
OrgId
:
ds
.
OrgId
,
Name
:
ds
.
Name
,
Url
:
ds
.
Url
,
Type
:
ds
.
Type
,
Access
:
ds
.
Access
,
Password
:
ds
.
Password
,
Database
:
ds
.
Database
,
User
:
ds
.
User
,
BasicAuth
:
ds
.
BasicAuth
,
BasicAuthUser
:
ds
.
BasicAuthUser
,
BasicAuthPassword
:
ds
.
BasicAuthPassword
,
WithCredentials
:
ds
.
WithCredentials
,
IsDefault
:
ds
.
IsDefault
,
JsonData
:
ds
.
JsonData
,
})
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment