mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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
This commit is contained in:
@@ -128,7 +128,7 @@ Error statuses:
|
||||
|
||||
```http
|
||||
HTTP/1.1 200
|
||||
Content-Type: application/json
|
||||
Content-Type: application/json
|
||||
|
||||
```
|
||||
## 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)
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
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) {
|
||||
|
Reference in New Issue
Block a user