MCPcopy
hub / github.com/apache/devlake / PutApiKey

Function PutApiKey

backend/server/api/apikeys/apikeys.go:96–113  ·  view source on GitHub ↗

@Summary Refresh an api key @Description Refresh an api key @Tags framework/api-keys @Accept application/json @Success 200 @Failure 400 {string} errcode.Error "Bad Request" @Failure 500 {string} errcode.Error "Internal Error" @Router /api-keys/:apiKeyId [put]

(c *gin.Context)

Source from the content-addressed store, hash-verified

94// @Failure 500 {string} errcode.Error "Internal Error"
95// @Router /api-keys/:apiKeyId [put]
96func PutApiKey(c *gin.Context) {
97 apiKeyId := c.Param("apiKeyId")
98 id, err := strconv.ParseUint(apiKeyId, 10, 64)
99 if err != nil {
100 shared.ApiOutputError(c, errors.BadInput.Wrap(err, "bad apiKeyId format supplied"))
101 return
102 }
103 user, exist := shared.GetUser(c)
104 if !exist {
105 logruslog.Global.Warn(nil, "user doesn't exist")
106 }
107 apiOutputApiKey, err := services.PutApiKey(user, id)
108 if err != nil {
109 shared.ApiOutputError(c, errors.Default.Wrap(err, "error regenerate api key"))
110 return
111 }
112 shared.ApiOutputSuccess(c, apiOutputApiKey, http.StatusOK)
113}
114
115// @Summary Create a new api key
116// @Description Create a new api key

Callers

nothing calls this directly

Calls 3

WrapMethod · 0.80
GetUserMethod · 0.80
WarnMethod · 0.65

Tested by

no test coverage detected