Skip to content

Commit

Permalink
SDK regeneration
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Feb 7, 2024
1 parent b9a1937 commit dbf36de
Show file tree
Hide file tree
Showing 22 changed files with 1,976 additions and 728 deletions.
291 changes: 200 additions & 91 deletions client/client.go

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions client/client_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// This file was auto-generated by Fern from our API Definition.

package client

import (
"net/http"
"testing"
"time"

"github.com/stretchr/testify/assert"
option "github.com/cohere-ai/cohere-go/v2/option"
assert "github.com/stretchr/testify/assert"
http "net/http"
testing "testing"
time "time"
)

func TestNewClient(t *testing.T) {
Expand All @@ -16,7 +18,7 @@ func TestNewClient(t *testing.T) {

t.Run("base url", func(t *testing.T) {
c := NewClient(
WithBaseURL("test.co"),
option.WithBaseURL("test.co"),
)
assert.Equal(t, "test.co", c.baseURL)
})
Expand All @@ -26,7 +28,7 @@ func TestNewClient(t *testing.T) {
Timeout: 5 * time.Second,
}
c := NewClient(
WithHTTPClient(httpClient),
option.WithHTTPClient(httpClient),
)
assert.Empty(t, c.baseURL)
})
Expand All @@ -35,7 +37,7 @@ func TestNewClient(t *testing.T) {
header := make(http.Header)
header.Set("X-API-Tenancy", "test")
c := NewClient(
WithHTTPHeader(header),
option.WithHTTPHeader(header),
)
assert.Empty(t, c.baseURL)
assert.Equal(t, "test", c.header.Get("X-API-Tenancy"))
Expand Down
50 changes: 22 additions & 28 deletions client/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,39 @@ package client

import (
core "github.com/cohere-ai/cohere-go/v2/core"
option "github.com/cohere-ai/cohere-go/v2/option"
http "net/http"
)

// WithBaseURL sets the client's base URL, overriding the
// default environment, if any.
func WithBaseURL(baseURL string) core.ClientOption {
return func(opts *core.ClientOptions) {
opts.BaseURL = baseURL
}
// WithBaseURL sets the base URL, overriding the default
// environment, if any.
func WithBaseURL(baseURL string) *core.BaseURLOption {
return option.WithBaseURL(baseURL)
}

// WithHTTPClient uses the given HTTPClient to issue all HTTP requests.
func WithHTTPClient(httpClient core.HTTPClient) core.ClientOption {
return func(opts *core.ClientOptions) {
opts.HTTPClient = httpClient
}
// WithHTTPClient uses the given HTTPClient to issue the request.
func WithHTTPClient(httpClient core.HTTPClient) *core.HTTPClientOption {
return option.WithHTTPClient(httpClient)
}

// WithHTTPHeader adds the given http.Header to all requests
// issued by the client.
func WithHTTPHeader(httpHeader http.Header) core.ClientOption {
return func(opts *core.ClientOptions) {
// Clone the headers so they can't be modified after the option call.
opts.HTTPHeader = httpHeader.Clone()
}
// WithHTTPHeader adds the given http.Header to the request.
func WithHTTPHeader(httpHeader http.Header) *core.HTTPHeaderOption {
return option.WithHTTPHeader(httpHeader)
}

// WithToken sets the 'Authorization: Bearer <token>' header on every request.
func WithToken(token string) core.ClientOption {
return func(opts *core.ClientOptions) {
opts.Token = token
}
// WithMaxAttempts configures the maximum number of retry attempts.
func WithMaxAttempts(attempts uint) *core.MaxAttemptsOption {
return option.WithMaxAttempts(attempts)
}

// WithClientName sets the clientName header on every request.
// WithToken sets the 'Authorization: Bearer <token>' request header.
func WithToken(token string) *core.TokenOption {
return option.WithToken(token)
}

// WithClientName sets the clientName request header.
//
// The name of the project that is making the request.
func WithClientName(clientName *string) core.ClientOption {
return func(opts *core.ClientOptions) {
opts.ClientName = clientName
}
func WithClientName(clientName *string) *core.ClientNameOption {
return option.WithClientName(clientName)
}
36 changes: 18 additions & 18 deletions connectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,46 @@ package api

type CreateConnectorRequest struct {
// A human-readable name for the connector.
Name string `json:"name"`
Name string `json:"name" url:"name"`
// A description of the connector.
Description *string `json:"description,omitempty"`
Description *string `json:"description,omitempty" url:"description,omitempty"`
// The URL of the connector that will be used to search for documents.
Url string `json:"url"`
Url string `json:"url" url:"url"`
// A list of fields to exclude from the prompt (fields remain in the document).
Excludes []string `json:"excludes,omitempty"`
Excludes []string `json:"excludes,omitempty" url:"excludes,omitempty"`
// The OAuth 2.0 configuration for the connector. Cannot be specified if service_auth is specified.
Oauth *CreateConnectorOAuth `json:"oauth,omitempty"`
Oauth *CreateConnectorOAuth `json:"oauth,omitempty" url:"oauth,omitempty"`
// Whether the connector is active or not.
Active *bool `json:"active,omitempty"`
Active *bool `json:"active,omitempty" url:"active,omitempty"`
// Whether a chat request should continue or not if the request to this connector fails.
ContinueOnFailure *bool `json:"continue_on_failure,omitempty"`
ContinueOnFailure *bool `json:"continue_on_failure,omitempty" url:"continue_on_failure,omitempty"`
// The service to service authentication configuration for the connector. Cannot be specified if oauth is specified.
ServiceAuth *CreateConnectorServiceAuth `json:"service_auth,omitempty"`
ServiceAuth *CreateConnectorServiceAuth `json:"service_auth,omitempty" url:"service_auth,omitempty"`
}

type ConnectorsListRequest struct {
// Maximum number of connectors to return [0, 100].
Limit *float64 `json:"-"`
Limit *float64 `json:"-" url:"limit,omitempty"`
// Number of connectors to skip before returning results [0, inf].
Offset *float64 `json:"-"`
Offset *float64 `json:"-" url:"offset,omitempty"`
}

type ConnectorsOAuthAuthorizeRequest struct {
// The URL to redirect to after the connector has been authorized.
AfterTokenRedirect *string `json:"-"`
AfterTokenRedirect *string `json:"-" url:"after_token_redirect,omitempty"`
}

type UpdateConnectorRequest struct {
// A human-readable name for the connector.
Name *string `json:"name,omitempty"`
Name *string `json:"name,omitempty" url:"name,omitempty"`
// The URL of the connector that will be used to search for documents.
Url *string `json:"url,omitempty"`
Url *string `json:"url,omitempty" url:"url,omitempty"`
// A list of fields to exclude from the prompt (fields remain in the document).
Excludes []string `json:"excludes,omitempty"`
Excludes []string `json:"excludes,omitempty" url:"excludes,omitempty"`
// The OAuth 2.0 configuration for the connector. Cannot be specified if service_auth is specified.
Oauth *CreateConnectorOAuth `json:"oauth,omitempty"`
Active *bool `json:"active,omitempty"`
ContinueOnFailure *bool `json:"continue_on_failure,omitempty"`
Oauth *CreateConnectorOAuth `json:"oauth,omitempty" url:"oauth,omitempty"`
Active *bool `json:"active,omitempty" url:"active,omitempty"`
ContinueOnFailure *bool `json:"continue_on_failure,omitempty" url:"continue_on_failure,omitempty"`
// The service to service authentication configuration for the connector. Cannot be specified if oauth is specified.
ServiceAuth *CreateConnectorServiceAuth `json:"service_auth,omitempty"`
ServiceAuth *CreateConnectorServiceAuth `json:"service_auth,omitempty" url:"service_auth,omitempty"`
}
Loading

0 comments on commit dbf36de

Please sign in to comment.