EXPERIMENTAL: this endpoint is experimental and is subject to change. nolint:revive // get-return: revive assumes get* must be a getter, but this is an HTTP handler.
(rw http.ResponseWriter, r *http.Request)
| 5391 | // |
| 5392 | //nolint:revive // get-return: revive assumes get* must be a getter, but this is an HTTP handler. |
| 5393 | func (api *API) getChatWorkspaceTTL(rw http.ResponseWriter, r *http.Request) { |
| 5394 | ctx := r.Context() |
| 5395 | raw, err := api.Database.GetChatWorkspaceTTL(ctx) |
| 5396 | if err != nil { |
| 5397 | if httpapi.Is404Error(err) { |
| 5398 | httpapi.ResourceNotFound(rw) |
| 5399 | return |
| 5400 | } |
| 5401 | httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{ |
| 5402 | Message: "Internal error fetching workspace TTL setting.", |
| 5403 | Detail: err.Error(), |
| 5404 | }) |
| 5405 | return |
| 5406 | } |
| 5407 | // Validate/default the stored value so callers always receive a |
| 5408 | // well-formed duration string. |
| 5409 | d, err := codersdk.ParseChatWorkspaceTTL(raw) |
| 5410 | if err != nil { |
| 5411 | httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{ |
| 5412 | Message: "Stored workspace TTL is invalid.", |
| 5413 | Detail: err.Error(), |
| 5414 | }) |
| 5415 | return |
| 5416 | } |
| 5417 | httpapi.Write(ctx, rw, http.StatusOK, codersdk.ChatWorkspaceTTLResponse{ |
| 5418 | WorkspaceTTLMillis: d.Milliseconds(), |
| 5419 | }) |
| 5420 | } |
| 5421 | |
| 5422 | // EXPERIMENTAL: this endpoint is experimental and is subject to change. |
| 5423 | func (api *API) putChatWorkspaceTTL(rw http.ResponseWriter, r *http.Request) { |
no test coverage detected