client

package
v1.15.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeForm = "application/x-www-form-urlencoded"
	ContentTypeJSON = "application/json"
)
View Source
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"
)
View Source
const AuthAudienceValue = "https://api.firebolt.io"

Variables

View Source
var AccountCache cache.Cache

Static caches on pacakge level

View Source
var URLCache cache.Cache

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

func MakeCanonicalUrl(url string) string

MakeCanonicalUrl checks whether url starts with https:// and if not prepends it

Types

type AuthenticationResponse

type AuthenticationResponse struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	ExpiresIn    int    `json:"expires_in"`
	TokenType    string `json:"token_type"`
	Scope        string `json:"scope"`
}

type BaseClient

type BaseClient struct {
	ClientID          string
	ClientSecret      string
	ApiEndpoint       string
	UserAgent         string
	ParameterGetter   func(context.Context, map[string]string) (map[string]string, error)
	AccessTokenGetter func() (string, error)
}

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

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)
}

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

func (c *ClientImpl) GetQueryParams(ctx context.Context, setStatements map[string]string) (map[string]string, error)

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

func (c *ClientImplCore) GetQueryParams(ctx context.Context, setStatements map[string]string) (map[string]string, error)

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 (c *ClientImplV0) GetAccountID(ctx context.Context, accountName string) (string, error)

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 (m *MockClient) GetConnectionParameters(ctx context.Context, engineName string, databaseName string) (string, map[string]string, error)

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)

type Response

type Response struct {
	// contains filtered or unexported fields
}

func DoHttpRequest

func DoHttpRequest(reqParams requestParameters) *Response

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

func MakeResponse

func MakeResponse(body io.ReadCloser, statusCode int, headers http.Header, err error) *Response

func (*Response) Body

func (r *Response) Body() io.ReadCloser

func (*Response) Content

func (r *Response) Content() ([]byte, error)

func (*Response) IsAsyncResponse added in v1.11.0

func (r *Response) IsAsyncResponse() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL