MCPcopy Index your code
hub / github.com/coder/coder / getChatTemplateAllowlist

Method getChatTemplateAllowlist

coderd/exp_chats.go:5645–5675  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

5643//
5644//nolint:revive // get-return: revive assumes get* must be a getter, but this is an HTTP handler.
5645func (api *API) getChatTemplateAllowlist(rw http.ResponseWriter, r *http.Request) {
5646 ctx := r.Context()
5647 if !api.Authorize(r, policy.ActionRead, rbac.ResourceDeploymentConfig) {
5648 httpapi.ResourceNotFound(rw)
5649 return
5650 }
5651 raw, err := api.Database.GetChatTemplateAllowlist(ctx)
5652 if err != nil {
5653 httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
5654 Message: "Internal error fetching chat template allowlist.",
5655 Detail: err.Error(),
5656 })
5657 return
5658 }
5659 parsed, parseErr := xjson.ParseUUIDList(raw)
5660 if parseErr != nil {
5661 httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
5662 Message: "Stored template allowlist is corrupt.",
5663 Detail: parseErr.Error(),
5664 })
5665 return
5666 }
5667 ids := make([]string, len(parsed))
5668 for i, id := range parsed {
5669 ids[i] = id.String()
5670 }
5671 resp := codersdk.ChatTemplateAllowlist{
5672 TemplateIDs: ids,
5673 }
5674 httpapi.Write(ctx, rw, http.StatusOK, resp)
5675}
5676
5677// EXPERIMENTAL: this endpoint is experimental and is subject to change.
5678func (api *API) putChatTemplateAllowlist(rw http.ResponseWriter, r *http.Request) {

Callers 1

chatTemplateAllowlistFunction · 0.80

Calls 8

AuthorizeMethod · 0.95
ResourceNotFoundFunction · 0.92
WriteFunction · 0.92
ParseUUIDListFunction · 0.92
ContextMethod · 0.65
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected