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

Method deleteChatUsageLimitOverride

coderd/exp_chats.go:1810–1853  ·  view source on GitHub ↗

@Summary Delete chat usage limit override @x-apidocgen {"skip": true} EXPERIMENTAL: this endpoint is experimental and is subject to change.

(rw http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

1808// @x-apidocgen {"skip": true}
1809// EXPERIMENTAL: this endpoint is experimental and is subject to change.
1810func (api *API) deleteChatUsageLimitOverride(rw http.ResponseWriter, r *http.Request) {
1811 ctx := r.Context()
1812 if !api.Authorize(r, policy.ActionUpdate, rbac.ResourceDeploymentConfig) {
1813 httpapi.Forbidden(rw)
1814 return
1815 }
1816
1817 userID, ok := parseChatUsageLimitUserID(rw, r)
1818 if !ok {
1819 return
1820 }
1821
1822 if _, err := api.Database.GetUserByID(ctx, userID); err != nil {
1823 if errors.Is(err, sql.ErrNoRows) {
1824 writeChatUsageLimitUserNotFound(ctx, rw)
1825 return
1826 }
1827 httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
1828 Message: "Failed to look up chat usage limit user.",
1829 Detail: err.Error(),
1830 })
1831 return
1832 }
1833 if _, err := api.Database.GetChatUsageLimitUserOverride(ctx, userID); err != nil {
1834 if errors.Is(err, sql.ErrNoRows) {
1835 writeChatUsageLimitOverrideNotFound(ctx, rw)
1836 return
1837 }
1838 httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
1839 Message: "Failed to look up chat usage limit override.",
1840 Detail: err.Error(),
1841 })
1842 return
1843 }
1844 if err := api.Database.DeleteChatUsageLimitUserOverride(ctx, userID); err != nil {
1845 httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
1846 Message: "Failed to delete chat usage limit override.",
1847 Detail: err.Error(),
1848 })
1849 return
1850 }
1851
1852 rw.WriteHeader(http.StatusNoContent)
1853}
1854
1855// @Summary Upsert chat usage limit group override
1856// @x-apidocgen {"skip": true}

Callers 1

Calls 13

AuthorizeMethod · 0.95
ForbiddenFunction · 0.92
WriteFunction · 0.92
ContextMethod · 0.65
GetUserByIDMethod · 0.65
IsMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected