@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)
| 94 | // @Failure 500 {string} errcode.Error "Internal Error" |
| 95 | // @Router /api-keys/:apiKeyId [put] |
| 96 | func 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 |