diff --git a/client.go b/client.go index d893058..bc2e96b 100644 --- a/client.go +++ b/client.go @@ -28,7 +28,6 @@ type Client struct { baseURL string apiKey string - region Region } // Option defines a configuration option for the Client. @@ -48,13 +47,6 @@ func WithAPIKey(key string) Option { } } -// WithRegion sets the region to use for the client. -func WithRegion(region Region) Option { - return func(c *Client) { - c.region = region - } -} - // WithHTTPClient sets the HTTP client to use for the client. func WithHTTPClient(client *http.Client) Option { return func(c *Client) { @@ -66,22 +58,13 @@ func WithHTTPClient(client *http.Client) Option { func NewClient(opts ...Option) *Client { client := &Client{ httpClient: http.DefaultClient, - region: RegionEU, - baseURL: "https://api.eu.tensorlake.ai/documents/v2", + baseURL: EndpointEU, apiKey: os.Getenv("TENSORLAKE_API_KEY"), } for _, opt := range opts { opt(client) } - - // For non on-premise regions, use the default base URL. - switch client.region { - case RegionEU: - client.baseURL = "https://api.eu.tensorlake.ai/documents/v2" - case RegionUS: - client.baseURL = "https://api.tensorlake.ai/documents/v2" - } return client } diff --git a/client_test.go b/client_test.go index 87aecbe..021243e 100644 --- a/client_test.go +++ b/client_test.go @@ -58,14 +58,6 @@ func TestNewClient(t *testing.T) { } }) - t.Run("with custom region", func(t *testing.T) { - client := NewClient(WithRegion(RegionUS)) - - if client == nil { - t.Fatal("NewClient returned nil") - } - }) - t.Run("with custom API key", func(t *testing.T) { client := NewClient(WithAPIKey("test-key")) @@ -73,31 +65,14 @@ func TestNewClient(t *testing.T) { t.Fatal("NewClient returned nil") } }) - - t.Run("with custom base URL and region", func(t *testing.T) { - client := NewClient(WithBaseURL("https://api.custom.com"), WithRegion(RegionUS)) - - if client == nil { - t.Fatal("NewClient returned nil") - } - }) - - t.Run("with on-premise region", func(t *testing.T) { - client := initializeTestClient(t) - - if client == nil { - t.Fatal("NewClient returned nil") - } - }) } func initializeTestClient(t *testing.T) *Client { base := os.Getenv("TENSORLAKE_BASE_URL") apiKey := os.Getenv("TENSORLAKE_API_KEY") - region := RegionUS if base == "" || apiKey == "" { t.Skip("TENSORLAKE_BASE_URL and TENSORLAKE_API_KEY must be set") } - return NewClient(WithBaseURL(base), WithAPIKey(apiKey), WithRegion(region)) + return NewClient(WithBaseURL(base), WithAPIKey(apiKey)) } diff --git a/doc.go b/doc.go index b88a160..af4d42c 100644 --- a/doc.go +++ b/doc.go @@ -23,7 +23,6 @@ // Create a client with your API key: // // c := tensorlake.NewClient( -// tensorlake.WithRegion(tensorlake.RegionOnPrem), // tensorlake.WithBaseURL("https://api.your-domain.com"), // tensorlake.WithAPIKey("your-api-key"), // ) diff --git a/enum.go b/enum.go index a4c327a..ce03d2b 100644 --- a/enum.go +++ b/enum.go @@ -14,15 +14,11 @@ package tensorlake -type Region string - const ( - // RegionEU is the European region. - RegionEU Region = "eu" - // RegionUS is the United States region. - RegionUS Region = "us" - // RegionOnPrem is the on-premise setup. - RegionOnPrem Region = "onprem" + // EndpointEU is the European endpoint. + EndpointEU string = "https://api.eu.tensorlake.ai/documents/v2" + // EndpointUS is the United States endpoint. + EndpointUS string = "https://api.tensorlake.ai/documents/v2" ) // ChunkingStrategy determines how the document is chunked into smaller pieces. @@ -247,3 +243,14 @@ const ( DatasetStatusIdle DatasetStatus = "idle" DatasetStatusProcessing DatasetStatus = "processing" ) + +type JobType string + +const ( + JobTypeParse JobType = "parse" + JobTypeRead JobType = "read" + JobTypeExtract JobType = "extract" + JobTypeClassify JobType = "classify" + JobTypeLegacy JobType = "legacy" + JobTypeDataset JobType = "dataset" +)