rockset

package module
Version: v0.12.4 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: Apache-2.0 Imports: 11 Imported by: 2

README

Rockset Go Client

CircleCI Documentation License GitHub issues Release

Official Go client library for Rockset

Installation

Install the Rockset Go client from Github:

go get github.com/rockset/rockset-go-client

or install it from a source code checkout:

cd $GOPATH/src/github.com
mkdir rockset
cd rockset
git clone git@github.com:rockset/rockset-go-client.git
go install rockset-go-client/rockclient.go

Usage

You can see a few examples in the godoc of how to create a collection, how to put documents in a collection and how to use SQL to query your collections.

client, err := rockset.NewClient()
if err != nil {
    log.Fatal(err)
}

ctx := context.TODO()
q := `SELECT * FROM "_events" LIMIT 1`

res, _, err := client.Query(ctx, q)
if err != nil {
    log.Fatal(err)
}

fmt.Printf("%+v\n", res)

Testing

For local development, add a replace directive in go.mod

replace (
       github.com/rockset/rockset-go-client/option => ./option
       github.com/rockset/rockset-go-client/openapi => ./openapi
)

There are a number of testable examples which require an API key, i.e. set the ROCKSET_APIKEY environment variable.

To run tests:

go test ./...
Code Coverage
go test ./... -coverprofile cover.out
go tool cover -func=cover.out
go tool cover -html=cover.out -o coverage.html

Support

Feel free to log issues against this client through GitHub.

License

The Rockset Go Client is licensed under the Apache 2.0 License

Documentation

Overview

Package rockset provides a go client to interact with the Rockset database.

The client uses the Rockset REST API https://docs.rockset.com/rest-api/, and is an OpenAPI generated code by https://openapi-generator.tech/.

It provides convenience functions for all API calls to make the generated client easier to use, by wrapping the API calls in methods that require passing a context.Context and having all required arguments in the method signature, so that as many errors as possible are caught at compile time instead of at runtime. It uses functional options for any optional arguments. The convenience methods return the payload data from the models package, to reduce the indirection.

All methods also automatically retries any retryable error returned by the Rockset API, using exponential back-off. The retryable errors are defined in rockset.RetryableErrors.

If a zerolog logger is set in the context, the methods will log to it. E.g.

console := zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: time.RFC3339}
log := zerolog.New(console).Level(zerolog.TraceLevel).With().Timestamp().Logger()
ctx := log.WithContext(context.Background())

rc, err := rockset.NewClient()
if err != nil {
  log.Fatalf("failed to create RockClient: %v," err)
}

wsName := "commons"
ws, err := rc.GetWorkspace(ctx, wsName)
if err != nil {
  log.Fatalf("failed to get workspace %s: %v", wsName, err)
}

Example log output

2021-05-28T13:11:46-07:00 TRC api call curation d=467.371958ms
2021-05-28T13:11:46-07:00 DBG total duration d=467.538875ms
2021-05-28T13:11:46-07:00 DBG get workspace successful name=commons
Example (QueryRaw)

Raw usage of the openapi client

ctx := context.TODO()

rc, err := rockset.NewClient()
if err != nil {
	log.Fatal(err)
}

q := rc.QueriesApi.Query(ctx)
rq := openapi.NewQueryRequestWithDefaults()

rq.Sql = openapi.NewQueryRequestSql("SELECT * FROM commons._events where label = :label")
rq.Sql.GenerateWarnings = openapi.PtrBool(true)
rq.Sql.ProfilingEnabled = openapi.PtrBool(true)
rq.Sql.DefaultRowLimit = openapi.PtrInt32(10)

rq.Sql.Parameters = &[]openapi.QueryParameter{
	{
		Name:  "label",
		Type:  "string",
		Value: "QUERY_SUCCESS",
	},
}

r, _, err := q.Body(*rq).Execute()
if err != nil {
	log.Fatal(err)
}

for _, c := range *r.Collections {
	fmt.Printf("collection: %s\n", c)
}
Output:

collection: commons._events
Example (S3)

Example code to first create an S3 integration, then create a collection from the integration, and finally clean up.

ctx := context.TODO()

rc, err := rockset.NewClient(rockset.WithHTTPDebug())
if err != nil {
	log.Fatal(err)
}

// create integration
r, err := rc.CreateS3Integration(ctx, "s3exampleIntegration",
	option.AWSRole("arn:aws:iam::469279130686:role/rockset-s3-integration"),
	option.WithS3IntegrationDescription("created by go example code"))
if err != nil {
	log.Fatalf("failed to create integration: %v", err)
}
fmt.Printf("integration created: %s\n", r.GetName())

// create collection
c, err := rc.CreateS3Collection(ctx, "commons", "s3example", "created by go example code",
	"s3exampleIntegration", "rockset-go-tests", "cities.csv",
	rockset.WithCSVFormat(
		[]string{"city", "country", "population", "visited"},
		[]rockset.ColumnType{
			rockset.ColumnTypeString, rockset.ColumnTypeString, rockset.ColumnTypeInteger, rockset.ColumnTypeBool,
		},
		option.WithEncoding("UTF-8"),
		option.WithEscapeChar("\\"),
		option.WithQuoteChar(`"`),
		option.WithSeparator(","),
	),
	option.WithCollectionFieldSchema("city", option.WithColumnIndexMode(option.ColumnIndexModeNoStore)),
	option.WithCollectionFieldMapping("test", false,
		option.OutputField("out", "CAST(:country AS string)", option.OnErrorSkip),
		option.InputField("country", option.FieldMissingSkip, false, "country")),
)
if err != nil {
	log.Fatalf("failed to create collection: %v", err)
}
fmt.Printf("collection created: %s\n", c.GetName())

// wait until collection is ready
err = rc.WaitUntilCollectionReady(ctx, "commons", "s3example")
if err != nil {
	log.Fatalf("failed to wait for collection to be ready: %v", err)
}
fmt.Printf("collection ready: %s\n", c.GetName())

// wait until there are at least 3 new documents in the collection
err = rc.WaitUntilCollectionDocuments(ctx, "commons", "s3example", 3)
if err != nil {
	log.Fatalf("failed to wait for new documents: %v", err)
}

// get number of documents
collection, err := rc.GetCollection(ctx, "commons", "s3example")
if err != nil {
	log.Fatalf("failed to get collection: %v", err)
}
fmt.Printf("collection documents: %d\n", collection.Stats.GetDocCount())

// delete the collection
err = rc.DeleteCollection(ctx, "commons", "s3example")
if err != nil {
	log.Fatalf("failed to delete collection: %v", err)
}
fmt.Printf("collection deleted: %s\n", c.GetName())

// wait until the collection is gone
err = rc.WaitUntilCollectionGone(ctx, "commons", "s3example")
if err != nil {
	log.Fatalf("failed to wait for collection to be gone: %v", err)
}
fmt.Printf("collection gone: %s\n", c.GetName())

// delete integration
err = rc.DeleteIntegration(ctx, "s3exampleIntegration")
if err != nil {
	log.Fatalf("failed to delete integration: %v", err)
}
fmt.Printf("integration deleted: %s\n", r.GetName())
Output:

integration created: s3exampleIntegration
collection created: s3example
collection ready: s3example
collection documents: 3
collection deleted: s3example
collection gone: s3example
integration deleted: s3exampleIntegration
Example (VCR)

Use govcr to record API calls as fixtures and then replay them. Note that this will record your API key so do not commit the saved "cassette" to a public repo. See https://github.com/seborama/govcr for information how to use govcr.

ctx := context.TODO()

cfg := govcr.VCRConfig{Logging: true, CassettePath: "vcr"}
rt := govcr.NewVCR("example", &cfg).Client

rc, err := rockset.NewClient(rockset.WithHTTPClient(rt))
if err != nil {
	log.Fatal(err)
}

// first request will make a HTTP request to the Rockset API
r, err := rc.GetOrganization(ctx)
if err != nil {
	log.Fatal(err)
}
fmt.Printf("org: %s\n", r.GetId())

// get a new client with recordings disabled
cfg.DisableRecording = true
rt = govcr.NewVCR("example", &cfg).Client
rc, err = rockset.NewClient(rockset.WithHTTPClient(rt))
if err != nil {
	log.Fatal(err)
}

// second request will replay the recorded information
r, err = rc.GetOrganization(ctx)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("org: %s\n", r.GetId())
Output:

org: rockset-circleci
org: rockset-circleci

Index

Examples

Constants

View Source
const APIKeyEnvironmentVariableName = "ROCKSET_APIKEY"

APIKeyEnvironmentVariableName is the environment variable name for the API key

View Source
const APIServerEnvironmentVariableName = "ROCKSET_APISERVER"

APIServerEnvironmentVariableName is the environment variable name for the API server

View Source
const DefaultAPIServer = "https://api.rs2.usw2.rockset.com"

DefaultAPIServer is the default Rockset API server to use

View Source
const LatestTag = "latest"

LatestTag is the query lambda tag for the latest version.

View Source
const Version = "0.12.3"

Version is the Rockset client version

Variables

RetryableErrors are the errors which will cause the operation to be retried

Functions

func RetryableError

func RetryableError(err error) bool

RetryableError returns true if err is a Rockset error that is retryable

Types

type ColumnType

type ColumnType int
const (
	ColumnTypeUnknown ColumnType = iota
	ColumnTypeBoolean
	ColumnTypeInteger
	ColumnTypeFloat
	ColumnTypeString
	ColumnTypeTime
	ColumnTypeDate
	ColumnTypeDatetime
	ColumnTypeTimestamp
	ColumnTypeBool
	ColumnTypeInt
)

func (ColumnType) String

func (c ColumnType) String() string

String returns the string representation of the ColumnType

type Error

type Error struct {
	// ErrorModel is the ErrorModel of the underlying error
	*openapi.ErrorModel
	// Cause is the underlying cause of the error
	Cause error
}

Error is an error returned by the Rockset REST API.

func NewError

func NewError(err error) Error

NewError wraps err in an Error that provides better error messages than the openapi.GenericOpenAPIError

func (Error) Error

func (e Error) Error() string

Error returns a string representation of the error

func (Error) IsNotFoundError

func (e Error) IsNotFoundError() bool

IsNotFoundError returns true when the error is from an underlying 404 response from the Rockset REST API.

func (Error) RateLimited

func (e Error) RateLimited() bool

RateLimited checks if the error came from a http.StatusTooManyRequests, which is used for rate limiting.

func (Error) Retryable

func (e Error) Retryable() bool

Retryable returns true if the error is in RetryableErrors

func (Error) Unwrap

func (e Error) Unwrap() error

Unwrap returns the cause of the Error

type ExponentialRetry

type ExponentialRetry struct {
	// MaxBackoff is the max time the exponential backoff can wait
	MaxBackoff time.Duration
	// WaitInterval is the initial interval wait between consecutive calls
	WaitInterval time.Duration
}

ExponentialRetry is used to perform API cal retries with exponential backoff

func (ExponentialRetry) Retry

func (r ExponentialRetry) Retry(ctx context.Context, retryFn RetryFunc) error

Retry retries retryFn until it returns false, or an error. Uses exponential backoff.

func (ExponentialRetry) RetryWithCheck

func (r ExponentialRetry) RetryWithCheck(ctx context.Context, checkFn RetryCheck) error

RetryWithCheck will retry checkFn until it returns false or an error. If checkFn returns false, RetryWithCheck will return nil, otherwise it'll return the error.

type Format

type Format func(params *openapi.FormatParams)

func WithCSVFormat

func WithCSVFormat(columnNames []string, columnTypes []ColumnType, options ...option.CSV) Format

WithCSVFormat is used by the create collection calls, to set the format to CSV. The columnNames and columnTypes must be of equal length, and it takes a list of optional option.CSV options.

WithCSVFormat(
  []string{"foo", "bar"},
  []ColumnType{ColumnTypeBoolean, ColumnTypeString},
  option.WithSeparator(";")
)

func WithJSONFormat

func WithJSONFormat() Format

WithJSONFormat sets the format to JSON.

func WithXMLFormat

func WithXMLFormat(xml openapi.XmlParams) Format

WithXMLFormat sets the format XML.

type KafkaFormat

type KafkaFormat string

KafkaFormat is the definition of the Kafka format

const (
	// KafkaFormatJSON is the JSON format for Kafka
	KafkaFormatJSON KafkaFormat = "JSON"
	// KafkaFormatAVRO is the AVRO format for Kafka
	KafkaFormatAVRO KafkaFormat = "AVRO"
)

func (KafkaFormat) String

func (f KafkaFormat) String() string

String returns the string representation of the Kafka format

type Retrier

type Retrier interface {
	// Retry will retry retryFn if it returns an error which is retryable
	Retry(ctx context.Context, retryFn RetryFunc) error
	// RetryWithCheck will retry checkFn until it returns false or an error
	RetryWithCheck(ctx context.Context, checkFunc RetryCheck) error
}

Retrier is the interface used by the RockClient convenience methods to retry an operation which returned a rockset.Error which is Retryable().

type RetryCheck

type RetryCheck func() (retry bool, err error)

RetryCheck is the function Retrier will call until the RetryFunc returns false or and error.

type RetryFunc

type RetryFunc func() (err error)

RetryFunc is the function Retrier will call as long as it returns an error which is retryable.

type RockClient

type RockClient struct {
	*openapi.APIClient
	RockConfig
}

RockClient is the client struct for making APi calls to Rockset.

Example (Query)

Query convenience method

ctx := context.TODO()

rc, err := rockset.NewClient()
if err != nil {
	log.Fatal(err)
}

r, err := rc.Query(ctx, "SELECT * FROM commons._events where label = :label",
	option.WithWarnings(), option.WithProfiling(), option.WithRowLimit(10),
	option.WithParameter("label", "string", "QUERY_SUCCESS"))
if err != nil {
	log.Fatal(err)
}

for _, c := range *r.Collections {
	fmt.Printf("collection: %s\n", c)
}
Output:

collection: commons._events
Example (QueryLambda)
ctx := context.TODO()

rc, err := rockset.NewClient()
if err != nil {
	log.Fatal(err)
}

r, err := rc.ExecuteQueryLambda(ctx, "commons", "eventType")
if err != nil {
	log.Fatal(err)
}

for _, c := range *r.Collections {
	fmt.Printf("collection: %s\n", c)
}
Output:

collection: commons._events
Example (QueryLambdaByTag)
ctx := context.TODO()

rc, err := rockset.NewClient()
if err != nil {
	log.Fatal(err)
}

r, err := rc.ExecuteQueryLambda(ctx, "commons", "eventType", option.WithTag("test"))
if err != nil {
	log.Fatal(err)
}

for _, c := range *r.Collections {
	fmt.Printf("collection: %s\n", c)
}
Output:

collection: commons._events
Example (QueryLambdaByVersion)
ctx := context.TODO()

rc, err := rockset.NewClient()
if err != nil {
	log.Fatal(err)
}

r, err := rc.ExecuteQueryLambda(ctx, "commons", "eventType",
	option.WithVersion("e4e67e8835063d03"))
if err != nil {
	log.Fatal(err)
}

for _, c := range *r.Collections {
	fmt.Printf("collection: %s\n", c)
}
Output:

collection: commons._events
Example (ValidateQuery)
ctx := context.TODO()

rc, err := rockset.NewClient()
if err != nil {
	log.Fatal(err)
}

r, err := rc.Query(ctx, "SELECT * FROM commons._events where label = :label",
	option.WithParameter("label", "string", "QUERY_SUCCESS"))
if err != nil {
	log.Fatal(err)
}

for _, c := range *r.Collections {
	fmt.Printf("collection: %s\n", c)
}
Output:

collection: commons._events

func NewClient

func NewClient(options ...RockOption) (*RockClient, error)

NewClient creates a new Rockset client.

Accessing the online database requires an API key and an API server to connect to, which are provided by through the ROCKSET_APIKEY and ROCKSET_APISERVER environment variables. If an API server isn't provided the DefaultAPIServer, is used.

c, err := rockset.NewClient()

They can or explicitly using the WithAPIKey() and WithAPIServer() options.

c, err := rockset.NewClient(rockset.WithAPIKey("..."), rockset.WithAPIServer("..."))

func (*RockClient) AddDocuments

func (rc *RockClient) AddDocuments(ctx context.Context, workspace, collection string,
	docs []interface{}) ([]openapi.DocumentStatus, error)

AddDocuments adds new documents to a collection

REST API documentation https://docs.rockset.com/rest-api/#adddocuments

func (*RockClient) CreateAPIKey

func (rc *RockClient) CreateAPIKey(ctx context.Context, keyName string) (openapi.ApiKey, error)

CreateAPIKey creates a new API key for the current user with the specified.

REST API documentation https://docs.rockset.com/rest-api/#createapikey

func (*RockClient) CreateAlias

func (rc *RockClient) CreateAlias(ctx context.Context, workspace, alias string, collections []string,
	options ...option.AliasOption) (openapi.Alias, error)

CreateAlias creates a new alias for a list of fully qualified collections, with an optional alias description using option.WithAliasDescription()

REST API documentation https://docs.rockset.com/rest-api/#createalias

func (*RockClient) CreateCollection

func (rc *RockClient) CreateCollection(ctx context.Context, workspace, name string,
	request *openapi.CreateCollectionRequest) (openapi.Collection, error)

CreateCollection is a convenience method to create a collection, which uses exponential backoff in case the API call is ratelimted. It will overwite the request.Name field with the argument name.

func (*RockClient) CreateDynamoDBCollection

func (rc *RockClient) CreateDynamoDBCollection(ctx context.Context,
	workspace, name, description, integration, region, tableName string, maxRCU int64,
	format Format, options ...option.CollectionOption) (openapi.Collection, error)

func (*RockClient) CreateDynamoDBIntegration

func (rc *RockClient) CreateDynamoDBIntegration(ctx context.Context, name string, creds option.AWSCredentialsFn,
	options ...option.DynamoDBIntegrationOption) (openapi.Integration, error)

func (*RockClient) CreateFileUploadCollection

func (rc *RockClient) CreateFileUploadCollection(ctx context.Context,
	workspace, name, description, fileName string, fileSize int64,
	fileUploadTime time.Time,
	format Format, options ...option.CollectionOption) (openapi.Collection, error)

func (*RockClient) CreateGCSCollection

func (rc *RockClient) CreateGCSCollection(ctx context.Context,
	workspace, name, description, integration, bucket, prefix string,
	format Format, options ...option.CollectionOption) (openapi.Collection, error)

func (*RockClient) CreateGCSIntegration

func (rc *RockClient) CreateGCSIntegration(ctx context.Context, name, serviceAccountKeyFileJSON string,
	options ...option.GCSIntegrationOption) (openapi.Integration, error)

func (*RockClient) CreateIPAllowlistNetworkPolicy

func (rc *RockClient) CreateIPAllowlistNetworkPolicy(ctx context.Context, name, ipAddress string,
	options ...option.IPAllowlistOption) (openapi.IpAllowlist, error)

CreateIPAllowlistNetworkPolicy creates a new IP allow list policy.

REST API documentation https://docs.rockset.com/rest-api/#createallowlistip

func (*RockClient) CreateKafkaCollection

func (rc *RockClient) CreateKafkaCollection(ctx context.Context,
	workspace, name, description, integration, topic string,
	format Format, options ...option.CollectionOption) (openapi.Collection, error)

func (*RockClient) CreateKafkaIntegration

func (rc *RockClient) CreateKafkaIntegration(ctx context.Context, name string, topics []string, format KafkaFormat,
	options ...option.KafkaIntegrationOption) (openapi.Integration, error)

func (*RockClient) CreateKinesisCollection

func (rc *RockClient) CreateKinesisCollection(ctx context.Context,
	workspace, name, description, integration, region, stream string,
	format Format, options ...option.CollectionOption) (openapi.Collection, error)

func (*RockClient) CreateKinesisIntegration

func (rc *RockClient) CreateKinesisIntegration(ctx context.Context, name string, creds option.AWSCredentialsFn,
	options ...option.KinesisIntegrationOption) (openapi.Integration, error)

func (*RockClient) CreateMongoDBCollection

func (rc *RockClient) CreateMongoDBCollection(ctx context.Context,
	workspace, name, description, integration, database, collection string,
	format Format, options ...option.CollectionOption) (openapi.Collection, error)

func (*RockClient) CreateMongoDBIntegration

func (rc *RockClient) CreateMongoDBIntegration(ctx context.Context, name, connectionURI string,
	options ...option.MongoDBIntegrationOption) (openapi.Integration, error)

func (*RockClient) CreateQueryLambda

func (rc *RockClient) CreateQueryLambda(ctx context.Context, workspace, name, sql string,
	options ...option.CreateQueryLambdaOption) (openapi.QueryLambdaVersion, error)

CreateQueryLambda creates a new query lambda.

https://docs.rockset.com/rest-api/#createquerylambda

func (*RockClient) CreateQueryLambdaTag

func (rc *RockClient) CreateQueryLambdaTag(ctx context.Context, workspace, name, version, tag string) (openapi.QueryLambdaTag, error)

CreateQueryLambdaTag creates a new tag for the query lambda version.

https://docs.rockset.com/rest-api/#createquerylambdatag

func (*RockClient) CreateRedshiftCollection

func (rc *RockClient) CreateRedshiftCollection(ctx context.Context,
	workspace, name, description, integration, database, schema, tableName string,
	format Format, options ...option.CollectionOption) (openapi.Collection, error)

func (*RockClient) CreateRedshiftIntegration

func (rc *RockClient) CreateRedshiftIntegration(ctx context.Context, name string, awsKeys option.AWSCredentialsFn,
	options ...option.RedshiftIntegrationOption) (openapi.Integration, error)

func (*RockClient) CreateS3Collection

func (rc *RockClient) CreateS3Collection(ctx context.Context,
	workspace, name, description, integration, bucket, pattern string,
	format Format, options ...option.CollectionOption) (openapi.Collection, error)

CreateS3Collection creates an S3 collection from an existing S3 integration. Not specifying a format will default to JSON.

func (*RockClient) CreateS3Integration

func (rc *RockClient) CreateS3Integration(ctx context.Context, name string, creds option.AWSCredentialsFn,
	options ...option.S3IntegrationOption) (openapi.Integration, error)

func (*RockClient) CreateSegmentIntegration

func (rc *RockClient) CreateSegmentIntegration(ctx context.Context, name, connectionString string,
	options ...option.SegmentIntegrationOption) (openapi.Integration, error)

func (*RockClient) CreateUser

func (rc *RockClient) CreateUser(ctx context.Context, email string, roles []string) (openapi.User, error)

CreateUser creates a new user.

REST API documentation https://docs.rockset.com/rest-api/#createuser

func (*RockClient) CreateWorkspace

func (rc *RockClient) CreateWorkspace(ctx context.Context, workspace string,
	options ...option.WorkspaceOption) (openapi.Workspace, error)

CreateWorkspace creates a new workspace, with an optional description.

REST API documentation https://docs.rockset.com/rest-api/#createworkspace

func (*RockClient) DeleteAPIKey

func (rc *RockClient) DeleteAPIKey(ctx context.Context, keyName string, options ...option.APIKeyOption) error

DeleteAPIKey deletes an API key. An admin can delete an api key for another user with option.ForUser().

REST API documentation https://docs.rockset.com/rest-api/#deleteapikey

func (*RockClient) DeleteAlias

func (rc *RockClient) DeleteAlias(ctx context.Context, workspace, alias string) error

DeleteAlias deletes an alias.

REST API documentation https://docs.rockset.com/rest-api/#deletealias

func (*RockClient) DeleteCollection

func (rc *RockClient) DeleteCollection(ctx context.Context, workspace, name string) error

func (*RockClient) DeleteDocuments

func (rc *RockClient) DeleteDocuments(ctx context.Context, workspace, collection string,
	docIDs []string) ([]openapi.DocumentStatus, error)

DeleteDocuments deletes documents from a collection

REST API documentation https://docs.rockset.com/rest-api/#deletedocuments

func (*RockClient) DeleteIPAllowlistNetworkPolicy

func (rc *RockClient) DeleteIPAllowlistNetworkPolicy(ctx context.Context, name string) error

DeleteIPAllowlistNetworkPolicy deletes an IP allow list policy by name.

REST API documentation https://docs.rockset.com/rest-api/#deleteallowlistip

func (*RockClient) DeleteIntegration

func (rc *RockClient) DeleteIntegration(ctx context.Context, name string) error

func (*RockClient) DeleteQueryLambda

func (rc *RockClient) DeleteQueryLambda(ctx context.Context, workspace, name string) error

DeleteQueryLambda deletes a query lambda.

https://docs.rockset.com/rest-api/#deletequerylambda

func (*RockClient) DeleteQueryLambdaTag

func (rc *RockClient) DeleteQueryLambdaTag(ctx context.Context, workspace, name, tag string) error

DeleteQueryLambdaTag deletes a query lambda tag.

https://docs.rockset.com/rest-api/#deletequerylambdatag

func (*RockClient) DeleteQueryLambdaVersion

func (rc *RockClient) DeleteQueryLambdaVersion(ctx context.Context, workspace, name, version string) error

DeleteQueryLambdaVersion deletes a query lambda version.

https://docs.rockset.com/rest-api/#deletequerylambdaversion

func (*RockClient) DeleteUser

func (rc *RockClient) DeleteUser(ctx context.Context, email string) error

DeleteUser deletes a user.

REST API documentation https://docs.rockset.com/rest-api/#deleteuser

func (*RockClient) DeleteWorkspace

func (rc *RockClient) DeleteWorkspace(ctx context.Context, name string) error

DeleteWorkspace deletes a workspace.

REST API documentation https://docs.rockset.com/rest-api/#deleteworkspace

func (*RockClient) ExecuteQueryLambda

func (rc *RockClient) ExecuteQueryLambda(ctx context.Context, workspace, name string,
	options ...option.QueryLambdaOption) (openapi.QueryResponse, error)

ExecuteQueryLambda executes a query lambda with optional query options.

func (*RockClient) GetAPIKey

func (rc *RockClient) GetAPIKey(ctx context.Context, name string,
	options ...option.APIKeyOption) (openapi.ApiKey, error)

GetAPIKey gets the named API key. An admin can get an api key for another user with option.ForUser().

REST API documentation https://docs.rockset.com/rest-api/#getapikey

func (*RockClient) GetAlias

func (rc *RockClient) GetAlias(ctx context.Context, workspace, alias string) (openapi.Alias, error)

GetAlias gets an alias

REST API documentation https://docs.rockset.com/rest-api/#getalias

func (*RockClient) GetCollection

func (rc *RockClient) GetCollection(ctx context.Context, workspace, name string) (openapi.Collection, error)

func (*RockClient) GetCurrentUser

func (rc *RockClient) GetCurrentUser(ctx context.Context) (openapi.User, error)

GetCurrentUser gets the current user.

REST API documentation https://docs.rockset.com/rest-api/#getcurrentuser

func (*RockClient) GetIPAllowlistNetworkPolicy

func (rc *RockClient) GetIPAllowlistNetworkPolicy(ctx context.Context, name string) (openapi.IpAllowlist, error)

GetIPAllowlistNetworkPolicy gets an IP allowlost policy by name.

REST API documentation https://docs.rockset.com/rest-api/#getallowlistip

func (*RockClient) GetIntegration

func (rc *RockClient) GetIntegration(ctx context.Context, name string) (openapi.Integration, error)

func (*RockClient) GetOrganization

func (rc *RockClient) GetOrganization(ctx context.Context) (openapi.Organization, error)

GetOrganization gets the current organization.

func (*RockClient) GetQueryLambdaVersion

func (rc *RockClient) GetQueryLambdaVersion(ctx context.Context,
	workspace, name, version string) (openapi.QueryLambdaVersion, error)

GetQueryLambdaVersion get the query lambda information for a specific version.

func (*RockClient) GetQueryLambdaVersionByTag

func (rc *RockClient) GetQueryLambdaVersionByTag(ctx context.Context,
	workspace, name, tag string) (openapi.QueryLambdaTag, error)

GetQueryLambdaVersionByTag gets the query lambda version for a tag.

func (*RockClient) GetVirtualInstance

func (rc *RockClient) GetVirtualInstance(ctx context.Context, vID string) (openapi.VirtualInstance, error)

GetVirtualInstance gets a virtual instance by the virtual instance uuid.

REST API documentation https://docs.rockset.com/rest-api/#getvirtualinstance

func (*RockClient) GetWorkspace

func (rc *RockClient) GetWorkspace(ctx context.Context, workspace string) (openapi.Workspace, error)

GetWorkspace gets a workspace.

REST API documentation https://docs.rockset.com/rest-api/#getworkspace

func (*RockClient) ListAPIKeys

func (rc *RockClient) ListAPIKeys(ctx context.Context, options ...option.APIKeyOption) ([]openapi.ApiKey, error)

ListAPIKeys list API keys. An admin can list api keys for another user with option.ForUser().

REST API documentation https://docs.rockset.com/rest-api/#listapikey

func (*RockClient) ListAliases

func (rc *RockClient) ListAliases(ctx context.Context, options ...option.ListAliasesOption) ([]openapi.Alias, error)

ListAliases lists all aliases for the organization, or for a workspace when using the option.WithAliasWorkspace() option.

REST API documentation https://docs.rockset.com/rest-api/#listalias

func (*RockClient) ListCollections

func (rc *RockClient) ListCollections(ctx context.Context, options ...option.ListCollectionOption) ([]openapi.Collection, error)

func (*RockClient) ListIPAllowlistEntries

func (rc *RockClient) ListIPAllowlistEntries(ctx context.Context) ([]openapi.IpAllowlist, error)

ListIPAllowlistEntries lists all IP allowlists policies.

REST API documentation https://docs.rockset.com/rest-api/#listallowlistips

func (*RockClient) ListIntegrations

func (rc *RockClient) ListIntegrations(ctx context.Context) ([]openapi.Integration, error)

func (*RockClient) ListQueryLambdaTagVersions

func (rc *RockClient) ListQueryLambdaTagVersions(ctx context.Context,
	tag string) ([]openapi.QueryLambdaVersion, error)

ListQueryLambdaTagVersions lists all query lambdas for the tag.

func (*RockClient) ListQueryLambdaTags

func (rc *RockClient) ListQueryLambdaTags(ctx context.Context,
	options ...option.ListQueryLambdaTagsOption) ([]openapi.QueryLambdaTag, error)

ListQueryLambdaTags lists all tags for the organization, or for a specific query lambda if the option.WithQueryLambda is used.

func (*RockClient) ListQueryLambdaVersions

func (rc *RockClient) ListQueryLambdaVersions(ctx context.Context,
	workspace, name string) ([]openapi.QueryLambdaVersion, error)

ListQueryLambdaVersions lists all versions for a query lambda.

func (*RockClient) ListQueryLambdas

func (rc *RockClient) ListQueryLambdas(ctx context.Context,
	options ...option.ListQueryLambdaOption) ([]openapi.QueryLambda, error)

ListQueryLambdas lists all query lambdas, unless the option.WithQueryLambdaWorkspace is used.

https://docs.rockset.com/rest-api/#listallquerylambdas

func (*RockClient) ListUsers

func (rc *RockClient) ListUsers(ctx context.Context) ([]openapi.User, error)

ListUsers lists all users.

REST API documentation https://docs.rockset.com/rest-api/#listusers

func (*RockClient) ListVirtualInstances

func (rc *RockClient) ListVirtualInstances(ctx context.Context) ([]openapi.VirtualInstance, error)

ListVirtualInstances lists all virtual instances.

REST API documentation https://docs.rockset.com/rest-api/#listvirtualinstances

func (*RockClient) ListWorkspaces

func (rc *RockClient) ListWorkspaces(ctx context.Context) ([]openapi.Workspace, error)

ListWorkspaces list all workspaces.

REST API documentation https://docs.rockset.com/rest-api/#listworkspaces

func (*RockClient) PatchDocuments

func (rc *RockClient) PatchDocuments(ctx context.Context, workspace, collection string,
	docs []openapi.PatchDocument) ([]openapi.DocumentStatus, error)

PatchDocuments updates (patches) existing documents in a collection

REST API documentation https://docs.rockset.com/rest-api/#patchdocuments

func (*RockClient) Query

func (rc *RockClient) Query(ctx context.Context, sql string,
	options ...option.QueryOption) (openapi.QueryResponse, error)

Query executes a sql query with optional option.QueryOption

func (*RockClient) UpdateAlias

func (rc *RockClient) UpdateAlias(ctx context.Context, workspace, alias string, collections []string,
	options ...option.AliasOption) error

UpdateAlias updates an alias

REST API documentation https://docs.rockset.com/rest-api/#updatealias

func (*RockClient) UpdateQueryLambda

func (rc *RockClient) UpdateQueryLambda(ctx context.Context, workspace, name, sql string,
	options ...option.CreateQueryLambdaOption) (openapi.QueryLambdaVersion, error)

UpdateQueryLambda updates an existing query lambda.

https://docs.rockset.com/rest-api/#updatequerylambda

func (*RockClient) UpdateVirtualInstance

func (rc *RockClient) UpdateVirtualInstance(ctx context.Context, vID string,
	options ...option.VirtualInstanceOption) (openapi.VirtualInstance, error)

UpdateVirtualInstance updates the properties of a virtual instance.

REST API documentation https://docs.rockset.com/rest-api/#setvirtualinstance

func (*RockClient) ValidateQuery

func (rc *RockClient) ValidateQuery(ctx context.Context, sql string,
	options ...option.QueryOption) (openapi.ValidateQueryResponse, error)

ValidateQuery validates a sql query with optional option.QueryOption

func (*RockClient) WaitUntilAliasAvailable

func (rc *RockClient) WaitUntilAliasAvailable(ctx context.Context, workspace, alias string) error

WaitUntilAliasAvailable waits until the alias is available.

func (*RockClient) WaitUntilCollectionDocuments

func (rc *RockClient) WaitUntilCollectionDocuments(ctx context.Context, workspace, name string, count int64) error

WaitUntilCollectionDocuments waits until the collection has at least count new documents

func (*RockClient) WaitUntilCollectionGone

func (rc *RockClient) WaitUntilCollectionGone(ctx context.Context, workspace, name string) error

WaitUntilCollectionGone waits until the a collection marked for deletion is gone, i.e. GetCollection() returns "not found".

func (*RockClient) WaitUntilCollectionReady

func (rc *RockClient) WaitUntilCollectionReady(ctx context.Context, workspace, name string) error

WaitUntilCollectionReady waits until the collection is ready.

type RockConfig

type RockConfig struct {
	// Retrier is the retry function used to retry API calls.
	Retrier
	// APIKey is the API key to use for authentication
	APIKey string
	// APIServer is the API server to connect to
	APIServer string
	// contains filtered or unexported fields
}

RockConfig contains the configurable options for the RockClient.

type RockOption

type RockOption func(rc *RockConfig)

RockOption is the type for RockClient options.

func WithAPIKey

func WithAPIKey(apiKey string) RockOption

WithAPIKey sets the API key to use

func WithAPIServer

func WithAPIServer(server string) RockOption

WithAPIServer sets the API server to connect to, and override the ROCKSET_APISERVER.

func WithHTTPClient

func WithHTTPClient(c *http.Client) RockOption

WithHTTPClient sets the HTTP client. Without this option RockClient uses the http.DefaultClient.

func WithHTTPDebug

func WithHTTPDebug() RockOption

WithHTTPDebug adds a http.RoundTripper that logs the request and response.

func WithRetry

func WithRetry(r Retrier) RockOption

WithRetry sets the Retrier the RockClient uses to retry requests which return a Error that can be retried.

Directories

Path Synopsis
openapi module
Package option contains optional arguments for rockset.RockClient convenience methods.
Package option contains optional arguments for rockset.RockClient convenience methods.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto