mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Implemented GetDataSourceByName API
This commit is contained in:
parent
252568c91b
commit
1a39d93b4e
@ -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)
|
||||||
|
@ -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,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user