Documentation
¶
Index ¶
- Constants
- func ConstructUserAgentString() (ua_string string)
- func GetHostNameURL() string
- func MakeCanonicalUrl(url string) string
- func NewHttpClient() *http.Client
- type AuthenticationResponse
- type BaseClient
- type Client
- type ClientImpl
- type ClientImplCore
- type ClientImplV0
- type ConnectionControl
- type MockClient
- func (m *MockClient) GetConnectionParameters(ctx context.Context, engineName string, databaseName string) (string, map[string]string, error)
- func (m *MockClient) IsNewVersion() bool
- func (m *MockClient) Query(ctx context.Context, engineUrl, query string, parameters map[string]string, ...) (*Response, error)
- func (m *MockClient) UploadParquet(ctx context.Context, engineUrl, sql string, parquetData []byte, ...) (*Response, error)
- type Response
Constants ¶
const ( ContentTypeForm = "application/x-www-form-urlencoded" ContentTypeJSON = "application/json" )
const ( ServiceAccountLoginURLSuffix = "/oauth/token" EngineUrlByAccountName = "/web/v3/account/%s/engineUrl" //API v0 UsernamePasswordURLSuffix = "/auth/v1/login" DefaultAccountURL = "/iam/v2/account" AccountIdByNameURL = "/iam/v2/accounts:getIdByName" EngineIdByNameURL = "/core/v1/accounts/%s/engines:getIdByName" EngineByIdURL = "/core/v1/accounts/%s/engines/%s" EngineUrlByDatabaseNameURL = "/core/v1/accounts/%s/engines:getURLByDatabaseName" )
const AuthAudienceValue = "https://api.firebolt.io"
Variables ¶
This section is empty.
Functions ¶
func ConstructUserAgentString ¶
func ConstructUserAgentString() (ua_string string)
ConstructUserAgentString returns a string with go, GoSDK and os type and versions additionally user can set "FIREBOLT_GO_DRIVERS" and "FIREBOLT_GO_CLIENTS" env variable, and they will be concatenated with the final user-agent string
func GetHostNameURL ¶
func GetHostNameURL() string
GetHostNameURL returns a hostname url, either default or overwritten with the environment variable
func MakeCanonicalUrl ¶
MakeCanonicalUrl checks whether url starts with https:// and if not prepends it
func NewHttpClient ¶ added in v1.16.0
NewHttpClient creates an *http.Client with a transport configured for connection pooling. Callers should reuse the returned client across requests so that idle TCP/TLS connections are kept alive.
Types ¶
type AuthenticationResponse ¶
type BaseClient ¶
type BaseClient struct {
ClientID string
ClientSecret string
ApiEndpoint string
UserAgent string
HttpClient *http.Client
ParameterGetter func(context.Context, map[string]string) (map[string]string, error)
AccessTokenGetter func() (string, error)
}
func (*BaseClient) Close ¶ added in v1.16.0
func (c *BaseClient) Close() error
Close releases resources held by the client, including idle HTTP connections.
func (*BaseClient) Query ¶
func (c *BaseClient) Query(ctx context.Context, engineUrl, query string, parameters map[string]string, control ConnectionControl) (*Response, error)
Query sends a query to the engine URL and populates queryResponse, if query was successful
func (*BaseClient) UploadParquet ¶ added in v1.16.0
func (c *BaseClient) UploadParquet(ctx context.Context, engineUrl, sql string, parquetData []byte, fileName string, parameters map[string]string, control ConnectionControl) (*Response, error)
UploadParquet sends a Parquet file via multipart form upload for batch INSERT. The form has two parts:
"sql" — the INSERT query, e.g. INSERT INTO t SELECT * FROM read_parquet('upload://<fileName>')
"<fileName>"— the Parquet file bytes
type Client ¶
type Client interface {
GetConnectionParameters(ctx context.Context, engineName string, databaseName string) (string, map[string]string, error)
Query(ctx context.Context, engineUrl, query string, parameters map[string]string, control ConnectionControl) (*Response, error)
UploadParquet(ctx context.Context, engineUrl, sql string, parquetData []byte, fileName string, parameters map[string]string, control ConnectionControl) (*Response, error)
}
func ClientFactory ¶
func ClientFactory(settings *types.FireboltSettings, apiEndpoint string) (Client, error)
ClientFactory sends an authentication request, and returns a newly constructed client object
type ClientImpl ¶
type ClientImpl struct {
ConnectedToSystemEngine bool
AccountName string
BaseClient
}
func MakeClient ¶
func MakeClient(settings *types.FireboltSettings, apiEndpoint string) (*ClientImpl, error)
func (*ClientImpl) GetConnectionParameters ¶
func (c *ClientImpl) GetConnectionParameters(ctx context.Context, engineName, databaseName string) (string, map[string]string, error)
GetConnectionParameters returns engine URL and parameters based on engineName and databaseName
func (*ClientImpl) GetQueryParams ¶
type ClientImplCore ¶ added in v1.10.0
type ClientImplCore struct {
AccountName string
BaseClient
}
func MakeClientCore ¶ added in v1.10.0
func MakeClientCore(settings *types.FireboltSettings) (*ClientImplCore, error)
func (*ClientImplCore) GetConnectionParameters ¶ added in v1.10.0
func (c *ClientImplCore) GetConnectionParameters(_ context.Context, _, databaseName string) (string, map[string]string, error)
GetConnectionParameters returns engine URL and parameters based on engineName and databaseName
func (*ClientImplCore) GetQueryParams ¶ added in v1.10.0
type ClientImplV0 ¶
type ClientImplV0 struct {
AccountID string
BaseClient
}
func MakeClientV0 ¶
func MakeClientV0(settings *types.FireboltSettings, apiEndpoint string) (*ClientImplV0, error)
func (*ClientImplV0) GetAccountID ¶ added in v1.8.0
func (*ClientImplV0) GetConnectionParameters ¶
func (c *ClientImplV0) GetConnectionParameters(ctx context.Context, engineName, databaseName string) (string, map[string]string, error)
GetConnectionParameters returns engine URL and engine name based on engineName and accountId
type ConnectionControl ¶
type ConnectionControl struct {
UpdateParameters func(string, string)
ResetParameters func(*[]string) // if list is nil, reset all parameters
SetEngineURL func(string)
}
ConnectionControl is a struct that holds methods for updating connection properties it's passed to Query method to allow it to update connection parameters and engine URL
type MockClient ¶
type MockClient struct {
ParametersCalled []map[string]string
// contains filtered or unexported fields
}
MockClient rudimentary mocks Client and tracks the parameters passed to Query
func MakeMockClient ¶
func MakeMockClient() *MockClient
func MakeMockClientWithError ¶
func MakeMockClientWithError(errorToRaise error) *MockClient
func (*MockClient) GetConnectionParameters ¶
func (*MockClient) IsNewVersion ¶
func (m *MockClient) IsNewVersion() bool
func (*MockClient) Query ¶
func (m *MockClient) Query(ctx context.Context, engineUrl, query string, parameters map[string]string, control ConnectionControl) (*Response, error)
func (*MockClient) UploadParquet ¶ added in v1.16.0
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
func DoHttpRequest ¶
DoHttpRequest sends a request using "POST" or "GET" method on a specified url additionally it passes the parameters and a bodyStr as a payload if accessToken is passed, it is used for authorization returns Response struct. httpClient may be nil, in which case http.DefaultClient is used.
func DoHttpRequestMultipart ¶ added in v1.16.0
func DoHttpRequestMultipart(httpClient *http.Client, reqParams requestParametersMultipart) *Response
DoHttpRequestMultipart sends a multipart form POST with an "sql" text field and a file attachment containing the Parquet data. httpClient may be nil, in which case http.DefaultClient is used.
func MakeResponse ¶
func (*Response) Body ¶
func (r *Response) Body() io.ReadCloser