Skip to content

Commit 9192f21

Browse files
authored
fix: Renamed Cloud client constructor for naming consistency (#258)
leaving NewCloudAPIClient for backward compatibility but making it deprecated Closes #257
1 parent f295c93 commit 9192f21

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

examples/v2/auth/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ func runCloudAuth() {
304304
}
305305

306306
// Create Chroma Cloud client
307-
client, err := v2.NewCloudAPIClient(
307+
client, err := v2.NewCloudClient(
308308
v2.WithCloudAPIKey(apiKey),
309309
v2.WithDatabaseAndTenant(database, tenant),
310310
)

pkg/api/v2/client_cloud.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type CloudAPIClient struct {
1313
*APIClientV2
1414
}
1515

16-
func NewCloudAPIClient(options ...ClientOption) (*CloudAPIClient, error) {
16+
func NewCloudClient(options ...ClientOption) (*CloudAPIClient, error) {
1717
bc, err := newBaseAPIClient()
1818
if err != nil {
1919
return nil, err
@@ -54,6 +54,11 @@ func NewCloudAPIClient(options ...ClientOption) (*CloudAPIClient, error) {
5454
return c, nil
5555
}
5656

57+
// Deprecated: use NewCloudClient instead
58+
func NewCloudAPIClient(options ...ClientOption) (*CloudAPIClient, error) {
59+
return NewCloudClient(options...)
60+
}
61+
5762
// WithCloudAPIKey sets the API key for the cloud client. It will automatically set a new TokenAuthCredentialsProvider.
5863
func WithCloudAPIKey(apiKey string) ClientOption {
5964
return func(c *BaseAPIClient) error {

pkg/api/v2/client_cloud_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func TestCloudClientHTTPIntegration(t *testing.T) {
2424
err := godotenv.Load("../../../.env")
2525
require.NoError(t, err)
2626
}
27-
client, err := NewCloudAPIClient(
27+
client, err := NewCloudClient(
2828
WithDebug(),
2929
WithDatabaseAndTenant(os.Getenv("CHROMA_DATABASE"), os.Getenv("CHROMA_TENANT")),
3030
WithCloudAPIKey(os.Getenv("CHROMA_API_KEY")),
@@ -204,7 +204,7 @@ func TestCloudClientHTTPIntegration(t *testing.T) {
204204

205205
t.Run("Without API Key", func(t *testing.T) {
206206
t.Setenv("CHROMA_API_KEY", "")
207-
client, err := NewCloudAPIClient(
207+
client, err := NewCloudClient(
208208
WithDebug(),
209209
WithDatabaseAndTenant("test_database", "test_tenant"),
210210
)
@@ -216,7 +216,7 @@ func TestCloudClientHTTPIntegration(t *testing.T) {
216216
t.Run("Without Tenant and DB", func(t *testing.T) {
217217
t.Setenv("CHROMA_TENANT", "")
218218
t.Setenv("CHROMA_DATABASE", "")
219-
client, err := NewCloudAPIClient(
219+
client, err := NewCloudClient(
220220
WithDebug(),
221221
WithCloudAPIKey("test"),
222222
)
@@ -227,7 +227,7 @@ func TestCloudClientHTTPIntegration(t *testing.T) {
227227
t.Run("With env tenant and DB", func(t *testing.T) {
228228
t.Setenv("CHROMA_TENANT", "test_tenant")
229229
t.Setenv("CHROMA_DATABASE", "test_database")
230-
client, err := NewCloudAPIClient(
230+
client, err := NewCloudClient(
231231
WithDebug(),
232232
WithCloudAPIKey("test"),
233233
)
@@ -241,7 +241,7 @@ func TestCloudClientHTTPIntegration(t *testing.T) {
241241
t.Setenv("CHROMA_TENANT", "test_tenant")
242242
t.Setenv("CHROMA_DATABASE", "test_database")
243243
t.Setenv("CHROMA_API_KEY", "test")
244-
client, err := NewCloudAPIClient(
244+
client, err := NewCloudClient(
245245
WithDebug(),
246246
)
247247
require.NoError(t, err)
@@ -259,7 +259,7 @@ func TestCloudClientHTTPIntegration(t *testing.T) {
259259
t.Setenv("CHROMA_TENANT", "test_tenant")
260260
t.Setenv("CHROMA_DATABASE", "test_database")
261261
t.Setenv("CHROMA_API_KEY", "test")
262-
client, err := NewCloudAPIClient(
262+
client, err := NewCloudClient(
263263
WithDebug(),
264264
WithCloudAPIKey("different_test_key"),
265265
WithDatabaseAndTenant("other_db", "other_tenant"),

0 commit comments

Comments
 (0)