MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / UpdateAccount

Method UpdateAccount

agent/app/service/agents.go:1047–1076  ·  view source on GitHub ↗
(req dto.AgentAccountUpdateReq)

Source from the content-addressed store, hash-verified

1045}
1046
1047func (a AgentService) UpdateAccount(req dto.AgentAccountUpdateReq) error {
1048 account, err := agentAccountRepo.GetFirst(repo.WithByID(req.ID))
1049 if err != nil {
1050 return err
1051 }
1052 provider := account.Provider
1053 resolvedInput, err := resolveAgentAccountInput(provider, req.APIKey, req.BaseURL)
1054 if err != nil {
1055 return err
1056 }
1057 account.Name = req.Name
1058 account.APIKey = resolvedInput.APIKey
1059 account.RememberAPIKey = req.RememberAPIKey
1060 account.BaseURL = resolvedInput.BaseURL
1061 account.APIType = req.APIType
1062 account.Remark = req.Remark
1063 account.Verified = true
1064
1065 if err := global.DB.Save(account).Error; err != nil {
1066 return err
1067 }
1068 terminalai.InvalidateTerminalRuntimeCache()
1069 terminalai.InvalidateFileAIRuntimeCache()
1070 if req.SyncAgents {
1071 if err := a.syncAgentsByAccount(account); err != nil {
1072 return err
1073 }
1074 }
1075 return nil
1076}
1077
1078func (a AgentService) PageAccounts(req dto.AgentAccountSearch) (int64, []dto.AgentAccountInfo, error) {
1079 var opts []repo.DBOption

Callers

nothing calls this directly

Calls 5

syncAgentsByAccountMethod · 0.95
resolveAgentAccountInputFunction · 0.85
GetFirstMethod · 0.65
WithByIDMethod · 0.65
SaveMethod · 0.65

Tested by

no test coverage detected