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

Method UpsertUserChatProviderKey

codersdk/chats.go:2213–2224  ·  view source on GitHub ↗

UpsertUserChatProviderKey creates or replaces a user API key for a provider.

(ctx context.Context, providerID uuid.UUID, req CreateUserChatProviderKeyRequest)

Source from the content-addressed store, hash-verified

2211
2212// UpsertUserChatProviderKey creates or replaces a user API key for a provider.
2213func (c *ExperimentalClient) UpsertUserChatProviderKey(ctx context.Context, providerID uuid.UUID, req CreateUserChatProviderKeyRequest) (UserChatProviderConfig, error) {
2214 res, err := c.Request(ctx, http.MethodPut, fmt.Sprintf("/api/experimental/chats/user-provider-configs/%s", providerID), req)
2215 if err != nil {
2216 return UserChatProviderConfig{}, xerrors.Errorf("upsert user chat provider key: %w", err)
2217 }
2218 defer res.Body.Close()
2219 if res.StatusCode != http.StatusOK {
2220 return UserChatProviderConfig{}, ReadBodyAsError(res)
2221 }
2222 var config UserChatProviderConfig
2223 return config, json.NewDecoder(res.Body).Decode(&config)
2224}
2225
2226// DeleteUserChatProviderKey deletes a user API key for a provider.
2227func (c *ExperimentalClient) DeleteUserChatProviderKey(ctx context.Context, providerID uuid.UUID) error {

Callers 2

Calls 4

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

Tested by 2