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.QueryRequestSql{Query: "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 ¶
- Constants
- Variables
- func RetryableError(err error) bool
- type ColumnType
- type Error
- type ExponentialRetry
- type Format
- type KafkaFormat
- type PatchDocument
- type PatchOperation
- type Retrier
- type RetryCheck
- type RetryFunc
- type RockClient
- func (rc *RockClient) AddDocuments(ctx context.Context, workspace, collection string, docs []interface{}) ([]openapi.DocumentStatus, error)
- func (rc *RockClient) CreateAPIKey(ctx context.Context, keyName string) (openapi.ApiKey, error)
- func (rc *RockClient) CreateAlias(ctx context.Context, workspace, alias string, collections []string, ...) (openapi.Alias, error)
- func (rc *RockClient) CreateCollection(ctx context.Context, workspace, name string, ...) (openapi.Collection, error)
- func (rc *RockClient) CreateDynamoDBCollection(ctx context.Context, ...) (openapi.Collection, error)
- func (rc *RockClient) CreateDynamoDBIntegration(ctx context.Context, name string, creds option.AWSCredentialsFn, ...) (openapi.Integration, error)
- func (rc *RockClient) CreateFileUploadCollection(ctx context.Context, workspace, name, description, fileName string, ...) (openapi.Collection, error)
- func (rc *RockClient) CreateGCSCollection(ctx context.Context, ...) (openapi.Collection, error)
- func (rc *RockClient) CreateGCSIntegration(ctx context.Context, name, serviceAccountKeyFileJSON string, ...) (openapi.Integration, error)
- func (rc *RockClient) CreateKafkaCollection(ctx context.Context, workspace, name, description, integration, topic string, ...) (openapi.Collection, error)
- func (rc *RockClient) CreateKafkaIntegration(ctx context.Context, name string, topics []string, format KafkaFormat, ...) (openapi.Integration, error)
- func (rc *RockClient) CreateKinesisCollection(ctx context.Context, ...) (openapi.Collection, error)
- func (rc *RockClient) CreateKinesisIntegration(ctx context.Context, name string, creds option.AWSCredentialsFn, ...) (openapi.Integration, error)
- func (rc *RockClient) CreateMongoDBCollection(ctx context.Context, ...) (openapi.Collection, error)
- func (rc *RockClient) CreateMongoDBIntegration(ctx context.Context, name, connectionURI string, ...) (openapi.Integration, error)
- func (rc *RockClient) CreateQueryLambda(ctx context.Context, workspace, name, sql string, ...) (openapi.QueryLambdaVersion, error)
- func (rc *RockClient) CreateQueryLambdaTag(ctx context.Context, workspace, name, version, tag string) (openapi.QueryLambdaTag, error)
- func (rc *RockClient) CreateRedshiftCollection(ctx context.Context, ...) (openapi.Collection, error)
- func (rc *RockClient) CreateRedshiftIntegration(ctx context.Context, name string, awsKeys option.AWSCredentialsFn, ...) (openapi.Integration, error)
- func (rc *RockClient) CreateS3Collection(ctx context.Context, ...) (openapi.Collection, error)
- func (rc *RockClient) CreateS3Integration(ctx context.Context, name string, creds option.AWSCredentialsFn, ...) (openapi.Integration, error)
- func (rc *RockClient) CreateSegmentIntegration(ctx context.Context, name, connectionString string, ...) (openapi.Integration, error)
- func (rc *RockClient) CreateUser(ctx context.Context, email string, roles []string) (openapi.User, error)
- func (rc *RockClient) CreateWorkspace(ctx context.Context, workspace string, options ...option.WorkspaceOption) (openapi.Workspace, error)
- func (rc *RockClient) DeleteAPIKey(ctx context.Context, keyName string, options ...option.APIKeyOption) error
- func (rc *RockClient) DeleteAlias(ctx context.Context, workspace, alias string) error
- func (rc *RockClient) DeleteCollection(ctx context.Context, workspace, name string) error
- func (rc *RockClient) DeleteDocuments(ctx context.Context, workspace, collection string, docIDs []string) ([]openapi.DocumentStatus, error)
- func (rc *RockClient) DeleteIntegration(ctx context.Context, name string) error
- func (rc *RockClient) DeleteQueryLambda(ctx context.Context, workspace, name string) error
- func (rc *RockClient) DeleteQueryLambdaVersion(ctx context.Context, workspace, name, version string) error
- func (rc *RockClient) DeleteUser(ctx context.Context, email string) error
- func (rc *RockClient) DeleteWorkspace(ctx context.Context, name string) error
- func (rc *RockClient) ExecuteQueryLambda(ctx context.Context, workspace, name string, ...) (openapi.QueryResponse, error)
- func (rc *RockClient) GetAPIKey(ctx context.Context, name string, options ...option.APIKeyOption) (openapi.ApiKey, error)
- func (rc *RockClient) GetAlias(ctx context.Context, workspace, alias string) (openapi.Alias, error)
- func (rc *RockClient) GetCollection(ctx context.Context, workspace, name string) (openapi.Collection, error)
- func (rc *RockClient) GetCurrentUser(ctx context.Context) (openapi.User, error)
- func (rc *RockClient) GetIntegration(ctx context.Context, name string) (openapi.Integration, error)
- func (rc *RockClient) GetOrganization(ctx context.Context) (openapi.Organization, error)
- func (rc *RockClient) GetQueryLambdaVersion(ctx context.Context, workspace, name, version string) (openapi.QueryLambdaVersion, error)
- func (rc *RockClient) GetQueryLambdaVersionByTag(ctx context.Context, workspace, name, tag string) (openapi.QueryLambdaTag, error)
- func (rc *RockClient) GetVirtualInstance(ctx context.Context, vID string) (openapi.VirtualInstance, error)
- func (rc *RockClient) GetWorkspace(ctx context.Context, workspace string) (openapi.Workspace, error)
- func (rc *RockClient) ListAPIKeys(ctx context.Context, options ...option.APIKeyOption) ([]openapi.ApiKey, error)
- func (rc *RockClient) ListAliases(ctx context.Context, options ...option.ListAliasesOption) ([]openapi.Alias, error)
- func (rc *RockClient) ListCollections(ctx context.Context, options ...option.ListCollectionOption) ([]openapi.Collection, error)
- func (rc *RockClient) ListIntegrations(ctx context.Context) ([]openapi.Integration, error)
- func (rc *RockClient) ListQueryLambdaTags(ctx context.Context, workspace, queryLambda string) ([]openapi.QueryLambdaTag, error)
- func (rc *RockClient) ListQueryLambdaVersions(ctx context.Context, workspace, name string) ([]openapi.QueryLambdaVersion, error)
- func (rc *RockClient) ListQueryLambdas(ctx context.Context, options ...option.ListQueryLambdaOption) ([]openapi.QueryLambda, error)
- func (rc *RockClient) ListUsers(ctx context.Context) ([]openapi.User, error)
- func (rc *RockClient) ListVirtualInstances(ctx context.Context) ([]openapi.VirtualInstance, error)
- func (rc *RockClient) ListWorkspaces(ctx context.Context) ([]openapi.Workspace, error)
- func (rc *RockClient) PatchDocuments(ctx context.Context, workspace, collection string, patches []PatchDocument) ([]openapi.DocumentStatus, error)
- func (rc *RockClient) Ping(ctx context.Context) error
- func (rc *RockClient) Query(ctx context.Context, sql string, options ...option.QueryOption) (openapi.QueryResponse, error)
- func (rc *RockClient) UpdateAlias(ctx context.Context, workspace, alias string, collections []string, ...) error
- func (rc *RockClient) UpdateQueryLambda(ctx context.Context, workspace, name, sql string, ...) (openapi.QueryLambdaVersion, error)
- func (rc *RockClient) UpdateVirtualInstance(ctx context.Context, vID string, options ...option.VirtualInstanceOption) (openapi.VirtualInstance, error)
- func (rc *RockClient) ValidateQuery(ctx context.Context, sql string, options ...option.QueryOption) (openapi.ValidateQueryResponse, error)
- func (rc *RockClient) WaitUntilAliasAvailable(ctx context.Context, workspace, alias string) error
- func (rc *RockClient) WaitUntilCollectionDocuments(ctx context.Context, workspace, name string, count int64) error
- func (rc *RockClient) WaitUntilCollectionGone(ctx context.Context, workspace, name string) error
- func (rc *RockClient) WaitUntilCollectionReady(ctx context.Context, workspace, name string) error
- type RockConfig
- type RockOption
Examples ¶
Constants ¶
const APIKeyEnvironmentVariableName = "ROCKSET_APIKEY"
APIKeyEnvironmentVariableName is the environment variable name for the API key
const APIServerEnvironmentVariableName = "ROCKSET_APISERVER"
APIServerEnvironmentVariableName is the environment variable name for the API server
const DefaultAPIServer = "https://api.rs2.usw2.rockset.com"
DefaultAPIServer is the default Rockset API server to use
const LatestTag = "latest"
LatestTag is the query lambda tag for the latest version.
const Version = "0.13.1"
Version is the Rockset client version
Variables ¶
var RetryableErrors = []int{ http.StatusTooManyRequests, http.StatusServiceUnavailable, http.StatusGatewayTimeout, }
RetryableErrors are the errors which will cause the operation to be retried
Functions ¶
func RetryableError ¶ added in v0.12.0
RetryableError returns true if err is a Rockset error that is retryable
Types ¶
type ColumnType ¶ added in v0.11.0
type ColumnType int
const ( ColumnTypeUnknown ColumnType = iota ColumnTypeBoolean ColumnTypeInteger ColumnTypeFloat ColumnTypeString ColumnTypeTime ColumnTypeDate ColumnTypeDatetime ColumnTypeTimestamp ColumnTypeBool ColumnTypeInt )
func (ColumnType) String ¶ added in v0.11.0
func (c ColumnType) String() string
String returns the string representation of the ColumnType
type Error ¶ added in v0.12.0
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 ¶ added in v0.12.0
NewError wraps err in an Error that provides better error messages than the openapi.GenericOpenAPIError
func (Error) IsNotFoundError ¶ added in v0.12.0
IsNotFoundError returns true when the error is from an underlying 404 response from the Rockset REST API.
func (Error) RateLimited ¶ added in v0.12.0
RateLimited checks if the error came from a http.StatusTooManyRequests, which is used for rate limiting.
type ExponentialRetry ¶ added in v0.12.0
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 ¶ added in v0.12.0
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 ¶ added in v0.12.0
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 ¶ added in v0.11.0
type Format func(params *openapi.FormatParams)
func WithCSVFormat ¶ added in v0.11.0
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 ¶ added in v0.11.0
func WithJSONFormat() Format
WithJSONFormat sets the format to JSON.
func WithXMLFormat ¶ added in v0.11.0
WithXMLFormat sets the format XML.
type KafkaFormat ¶ added in v0.12.0
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 ¶ added in v0.12.0
func (f KafkaFormat) String() string
String returns the string representation of the Kafka format
type PatchDocument ¶ added in v0.13.0
type PatchDocument struct { ID string `json:"_id"` Patches []PatchOperation `json:"patch"` }
type PatchOperation ¶ added in v0.13.0
type Retrier ¶ added in v0.12.0
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 ¶ added in v0.12.0
RetryCheck is the function Retrier will call until the RetryFunc returns false or and error.
type RetryFunc ¶ added in v0.12.0
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 ¶ added in v0.8.0
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 ¶ added in v0.12.0
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 ¶ added in v0.12.0
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 ¶ added in v0.12.0
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 ¶ added in v0.12.0
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 ¶ added in v0.11.0
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 ¶ added in v0.11.0
func (rc *RockClient) CreateDynamoDBIntegration(ctx context.Context, name string, creds option.AWSCredentialsFn, options ...option.DynamoDBIntegrationOption) (openapi.Integration, error)
func (*RockClient) CreateFileUploadCollection ¶ added in v0.11.0
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 ¶ added in v0.11.0
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 ¶ added in v0.11.0
func (rc *RockClient) CreateGCSIntegration(ctx context.Context, name, serviceAccountKeyFileJSON string, options ...option.GCSIntegrationOption) (openapi.Integration, error)
func (*RockClient) CreateKafkaCollection ¶ added in v0.11.0
func (rc *RockClient) CreateKafkaCollection(ctx context.Context, workspace, name, description, integration, topic string, format Format, options ...option.CollectionOption) (openapi.Collection, error)
func (*RockClient) CreateKafkaIntegration ¶ added in v0.12.0
func (rc *RockClient) CreateKafkaIntegration(ctx context.Context, name string, topics []string, format KafkaFormat, options ...option.KafkaIntegrationOption) (openapi.Integration, error)
func (*RockClient) CreateKinesisCollection ¶ added in v0.11.0
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 ¶ added in v0.11.0
func (rc *RockClient) CreateKinesisIntegration(ctx context.Context, name string, creds option.AWSCredentialsFn, options ...option.KinesisIntegrationOption) (openapi.Integration, error)
func (*RockClient) CreateMongoDBCollection ¶ added in v0.11.0
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 ¶ added in v0.12.0
func (rc *RockClient) CreateMongoDBIntegration(ctx context.Context, name, connectionURI string, options ...option.MongoDBIntegrationOption) (openapi.Integration, error)
func (*RockClient) CreateQueryLambda ¶ added in v0.12.4
func (rc *RockClient) CreateQueryLambda(ctx context.Context, workspace, name, sql string, options ...option.CreateQueryLambdaOption) (openapi.QueryLambdaVersion, error)
CreateQueryLambda creates a new query lambda.
func (*RockClient) CreateQueryLambdaTag ¶ added in v0.12.4
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.
func (*RockClient) CreateRedshiftCollection ¶ added in v0.11.0
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 ¶ added in v0.12.0
func (rc *RockClient) CreateRedshiftIntegration(ctx context.Context, name string, awsKeys option.AWSCredentialsFn, options ...option.RedshiftIntegrationOption) (openapi.Integration, error)
func (*RockClient) CreateS3Collection ¶ added in v0.11.0
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 ¶ added in v0.11.0
func (rc *RockClient) CreateS3Integration(ctx context.Context, name string, creds option.AWSCredentialsFn, options ...option.S3IntegrationOption) (openapi.Integration, error)
func (*RockClient) CreateSegmentIntegration ¶ added in v0.12.0
func (rc *RockClient) CreateSegmentIntegration(ctx context.Context, name, connectionString string, options ...option.SegmentIntegrationOption) (openapi.Integration, error)
func (*RockClient) CreateUser ¶ added in v0.12.0
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 ¶ added in v0.9.1
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 ¶ added in v0.12.0
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 ¶ added in v0.12.0
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 ¶ added in v0.11.0
func (rc *RockClient) DeleteCollection(ctx context.Context, workspace, name string) error
func (*RockClient) DeleteDocuments ¶ added in v0.12.0
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) DeleteIntegration ¶ added in v0.11.0
func (rc *RockClient) DeleteIntegration(ctx context.Context, name string) error
func (*RockClient) DeleteQueryLambda ¶ added in v0.12.4
func (rc *RockClient) DeleteQueryLambda(ctx context.Context, workspace, name string) error
DeleteQueryLambda deletes a query lambda.
func (*RockClient) DeleteQueryLambdaVersion ¶ added in v0.12.4
func (rc *RockClient) DeleteQueryLambdaVersion(ctx context.Context, workspace, name, version string) error
DeleteQueryLambdaVersion deletes a query lambda version.
func (*RockClient) DeleteUser ¶ added in v0.12.0
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 ¶ added in v0.9.1
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 ¶ added in v0.11.0
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 ¶ added in v0.12.0
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 ¶ added in v0.12.0
GetAlias gets an alias
REST API documentation https://docs.rockset.com/rest-api/#getalias
func (*RockClient) GetCollection ¶ added in v0.11.0
func (rc *RockClient) GetCollection(ctx context.Context, workspace, name string) (openapi.Collection, error)
func (*RockClient) GetCurrentUser ¶ added in v0.12.0
GetCurrentUser gets the current user.
REST API documentation https://docs.rockset.com/rest-api/#getcurrentuser
func (*RockClient) GetIntegration ¶ added in v0.12.3
func (rc *RockClient) GetIntegration(ctx context.Context, name string) (openapi.Integration, error)
func (*RockClient) GetOrganization ¶ added in v0.12.0
func (rc *RockClient) GetOrganization(ctx context.Context) (openapi.Organization, error)
GetOrganization gets the current organization.
func (*RockClient) GetQueryLambdaVersion ¶ added in v0.12.3
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 ¶ added in v0.12.3
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 ¶ added in v0.12.0
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 ¶ added in v0.9.1
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 ¶ added in v0.12.0
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 ¶ added in v0.12.0
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 ¶ added in v0.12.3
func (rc *RockClient) ListCollections(ctx context.Context, options ...option.ListCollectionOption) ([]openapi.Collection, error)
func (*RockClient) ListIntegrations ¶ added in v0.12.3
func (rc *RockClient) ListIntegrations(ctx context.Context) ([]openapi.Integration, error)
func (*RockClient) ListQueryLambdaTags ¶ added in v0.12.3
func (rc *RockClient) ListQueryLambdaTags(ctx context.Context, workspace, queryLambda string) ([]openapi.QueryLambdaTag, error)
ListQueryLambdaTags lists all tags for a query lambda.
func (*RockClient) ListQueryLambdaVersions ¶ added in v0.12.3
func (rc *RockClient) ListQueryLambdaVersions(ctx context.Context, workspace, name string) ([]openapi.QueryLambdaVersion, error)
ListQueryLambdaVersions lists all versions for a query lambda.
func (*RockClient) ListQueryLambdas ¶ added in v0.12.3
func (rc *RockClient) ListQueryLambdas(ctx context.Context, options ...option.ListQueryLambdaOption) ([]openapi.QueryLambda, error)
ListQueryLambdas lists all query lambdas, unless the option.WithQueryLambdaWorkspace is used.
func (*RockClient) ListUsers ¶ added in v0.12.0
ListUsers lists all users.
REST API documentation https://docs.rockset.com/rest-api/#listusers
func (*RockClient) ListVirtualInstances ¶ added in v0.12.0
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 ¶ added in v0.9.1
ListWorkspaces list all workspaces.
REST API documentation https://docs.rockset.com/rest-api/#listworkspaces
func (*RockClient) PatchDocuments ¶ added in v0.12.0
func (rc *RockClient) PatchDocuments(ctx context.Context, workspace, collection string, patches []PatchDocument) ([]openapi.DocumentStatus, error)
PatchDocuments patches (updates) existing documents in a collection. This convenience method does not use the generated client, as it takes values as map[string]interface{} which doesn't work when you want to patch e.g. a top-level boolean value.
REST API documentation https://docs.rockset.com/rest-api/#patchdocuments
func (*RockClient) Ping ¶ added in v0.13.0
func (rc *RockClient) Ping(ctx context.Context) error
Ping connects to the Rockset API server and can be used to verify connectivity. It does not require authentication, so to test that use the GetOrganization() method instead.
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 ¶ added in v0.12.0
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 ¶ added in v0.12.4
func (rc *RockClient) UpdateQueryLambda(ctx context.Context, workspace, name, sql string, options ...option.CreateQueryLambdaOption) (openapi.QueryLambdaVersion, error)
UpdateQueryLambda updates an existing query lambda.
func (*RockClient) UpdateVirtualInstance ¶ added in v0.12.0
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 ¶ added in v0.11.0
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 ¶ added in v0.12.0
func (rc *RockClient) WaitUntilAliasAvailable(ctx context.Context, workspace, alias string) error
WaitUntilAliasAvailable waits until the alias is available.
func (*RockClient) WaitUntilCollectionDocuments ¶ added in v0.12.0
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 ¶ added in v0.12.0
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 ¶ added in v0.12.0
func (rc *RockClient) WaitUntilCollectionReady(ctx context.Context, workspace, name string) error
WaitUntilCollectionReady waits until the collection is ready.
type RockConfig ¶ added in v0.12.0
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 ¶ added in v0.8.0
type RockOption func(rc *RockConfig)
RockOption is the type for RockClient options.
func WithAPIKey ¶ added in v0.8.0
func WithAPIKey(apiKey string) RockOption
WithAPIKey sets the API key to use
func WithAPIServer ¶ added in v0.8.0
func WithAPIServer(server string) RockOption
WithAPIServer sets the API server to connect to, and override the ROCKSET_APISERVER.
func WithHTTPClient ¶ added in v0.8.0
func WithHTTPClient(c *http.Client) RockOption
WithHTTPClient sets the HTTP client. Without this option RockClient uses the http.DefaultClient.
func WithHTTPDebug ¶ added in v0.12.0
func WithHTTPDebug() RockOption
WithHTTPDebug adds a http.RoundTripper that logs the request and response.
func WithRetry ¶ added in v0.12.0
func WithRetry(r Retrier) RockOption
WithRetry sets the Retrier the RockClient uses to retry requests which return a Error that can be retried.