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

Method UpsertUserAIProviderKey

codersdk/chats.go:2168–2179  ·  view source on GitHub ↗

UpsertUserAIProviderKey creates or replaces a user API key for an AI provider.

(ctx context.Context, user string, providerID uuid.UUID, req CreateUserAIProviderKeyRequest)

Source from the content-addressed store, hash-verified

2166
2167// UpsertUserAIProviderKey creates or replaces a user API key for an AI provider.
2168func (c *ExperimentalClient) UpsertUserAIProviderKey(ctx context.Context, user string, providerID uuid.UUID, req CreateUserAIProviderKeyRequest) (UserAIProviderKeyConfig, error) {
2169 res, err := c.Request(ctx, http.MethodPut, fmt.Sprintf("%s/%s", userAIProviderKeysPath(user), providerID), req)
2170 if err != nil {
2171 return UserAIProviderKeyConfig{}, xerrors.Errorf("upsert user AI provider key: %w", err)
2172 }
2173 defer res.Body.Close()
2174 if res.StatusCode != http.StatusOK {
2175 return UserAIProviderKeyConfig{}, ReadBodyAsError(res)
2176 }
2177 var config UserAIProviderKeyConfig
2178 return config, json.NewDecoder(res.Body).Decode(&config)
2179}
2180
2181// DeleteUserAIProviderKey deletes a user API key for an AI provider.
2182func (c *ExperimentalClient) DeleteUserAIProviderKey(ctx context.Context, user string, providerID uuid.UUID) error {

Callers 2

TestUserAIProviderKeysFunction · 0.95

Calls 5

ReadBodyAsErrorFunction · 0.85
userAIProviderKeysPathFunction · 0.70
CloseMethod · 0.65
RequestMethod · 0.45
ErrorfMethod · 0.45

Tested by 2

TestUserAIProviderKeysFunction · 0.76