Commit 6dd109b9 by Agnès Toulet Committed by GitHub

API: return resource ID for auth key creation, folder permissions update and…

API: return resource ID for auth key creation, folder permissions update and user invite complete endpoints (#27419)

* API: add ID to auth key and folder endpoints

* API: add test for folder permissions update

* API: add created user id for /invite/complete endpoint
parent 61bd33c2
......@@ -128,7 +128,7 @@ Error statuses:
HTTP/1.1 200
Content-Type: application/json
{"name":"mykey","key":"eyJrIjoiWHZiSWd3NzdCYUZnNUtibE9obUpESmE3bzJYNDRIc0UiLCJuIjoibXlrZXkiLCJpZCI6MX1="}
{"name":"mykey","key":"eyJrIjoiWHZiSWd3NzdCYUZnNUtibE9obUpESmE3bzJYNDRIc0UiLCJuIjoibXlrZXkiLCJpZCI6MX1=","id":1}
```
## Delete API Key
......
......@@ -138,7 +138,7 @@ HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 35
{"message":"Folder permissions updated"}
{"message":"Folder permissions updated","id":1,"title":"Department ABC"}
```
Status Codes:
......
......@@ -80,8 +80,10 @@ func (hs *HTTPServer) AddAPIKey(c *models.ReqContext, cmd models.AddApiKeyComman
}
result := &dtos.NewApiKeyResult{
ID: cmd.Result.Id,
Name: cmd.Result.Name,
Key: newKeyInfo.ClientSecret}
Key: newKeyInfo.ClientSecret,
}
return JSON(200, result)
}
package dtos
type NewApiKeyResult struct {
ID int64 `json:"id"`
Name string `json:"name"`
Key string `json:"key"`
}
......@@ -8,6 +8,7 @@ import (
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/dashboards"
"github.com/grafana/grafana/pkg/services/guardian"
"github.com/grafana/grafana/pkg/util"
)
func GetFolderPermissionList(c *models.ReqContext) Response {
......@@ -109,5 +110,9 @@ func UpdateFolderPermissions(c *models.ReqContext, apiCmd dtos.UpdateDashboardAc
return Error(500, "Failed to create permission", err)
}
return Success("Folder permissions updated")
return JSON(200, util.DynMap{
"message": "Folder permissions updated",
"id": folder.Id,
"title": folder.Title,
})
}
......@@ -125,6 +125,10 @@ func TestFolderPermissionApiEndpoint(t *testing.T) {
updateFolderPermissionScenario("When calling POST on", "/api/folders/uid/permissions", "/api/folders/:uid/permissions", cmd, func(sc *scenarioContext) {
callUpdateFolderPermissions(sc)
So(sc.resp.Code, ShouldEqual, 200)
respJSON, err := simplejson.NewJson(sc.resp.Body.Bytes())
So(err, ShouldBeNil)
So(respJSON.Get("id").MustInt(), ShouldEqual, 1)
So(respJSON.Get("title").MustString(), ShouldEqual, "Folder")
})
Reset(func() {
......
......@@ -211,7 +211,10 @@ func (hs *HTTPServer) CompleteInvite(c *models.ReqContext, completeInvite dtos.C
metrics.MApiUserSignUpCompleted.Inc()
metrics.MApiUserSignUpInvite.Inc()
return Success("User created and logged in")
return JSON(200, util.DynMap{
"message": "User created and logged in",
"id": user.Id,
})
}
func updateTempUserStatus(code string, status models.TempUserStatus) (bool, Response) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment