mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge pull request #4291 from utkarshcmu/ds-api
Pulled out the common code
This commit is contained in:
commit
1509b4cb6e
@ -52,24 +52,9 @@ func GetDataSourceById(c *middleware.Context) Response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ds := query.Result
|
ds := query.Result
|
||||||
|
dtos := convertModelToDtos(ds)
|
||||||
|
|
||||||
return Json(200, &dtos.DataSource{
|
return Json(200, &dtos)
|
||||||
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,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteDataSource(c *middleware.Context) {
|
func DeleteDataSource(c *middleware.Context) {
|
||||||
@ -145,8 +130,13 @@ func GetDataSourceByName(c *middleware.Context) Response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ds := query.Result
|
ds := query.Result
|
||||||
|
dtos := convertModelToDtos(ds)
|
||||||
|
|
||||||
return Json(200, &dtos.DataSource{
|
return Json(200, &dtos)
|
||||||
|
}
|
||||||
|
|
||||||
|
func convertModelToDtos(ds m.DataSource) dtos.DataSource {
|
||||||
|
return dtos.DataSource{
|
||||||
Id: ds.Id,
|
Id: ds.Id,
|
||||||
OrgId: ds.OrgId,
|
OrgId: ds.OrgId,
|
||||||
Name: ds.Name,
|
Name: ds.Name,
|
||||||
@ -162,5 +152,5 @@ func GetDataSourceByName(c *middleware.Context) Response {
|
|||||||
WithCredentials: ds.WithCredentials,
|
WithCredentials: ds.WithCredentials,
|
||||||
IsDefault: ds.IsDefault,
|
IsDefault: ds.IsDefault,
|
||||||
JsonData: ds.JsonData,
|
JsonData: ds.JsonData,
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user