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.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.WithInsertOnly(), option.WithFieldMappingQuery("SELECT * FROM _input"), ) 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 HA
- type KafkaFormat
- type PatchDocument
- type PatchOperation
- type Querier
- 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, options ...option.APIKeyRoleOption) (openapi.ApiKey, error)
- func (rc *RockClient) CreateAlias(ctx context.Context, workspace, alias string, collections []string, ...) (openapi.Alias, error)
- func (rc *RockClient) CreateAzureBlobStorageIntegration(ctx context.Context, name string, connection string) (openapi.Integration, 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) CreateRole(ctx context.Context, roleName string, options ...option.RoleOption) (openapi.Role, 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) CreateView(ctx context.Context, workspace, view, query string, ...) (openapi.View, 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) DeleteQueryLambdaTag(ctx context.Context, workspace, name, tag string) error
- func (rc *RockClient) DeleteQueryLambdaVersion(ctx context.Context, workspace, name, version string) error
- func (rc *RockClient) DeleteRole(ctx context.Context, roleName string) error
- func (rc *RockClient) DeleteUser(ctx context.Context, email string) error
- func (rc *RockClient) DeleteView(ctx context.Context, workspace, view 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) GetRole(ctx context.Context, roleName string) (openapi.Role, error)
- func (rc *RockClient) GetView(ctx context.Context, workspace, name string) (openapi.View, 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) ListRoles(ctx context.Context) ([]openapi.Role, error)
- func (rc *RockClient) ListUsers(ctx context.Context) ([]openapi.User, error)
- func (rc *RockClient) ListViews(ctx context.Context, options ...option.ListViewOption) ([]openapi.View, 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) UpdateRole(ctx context.Context, roleName string, options ...option.RoleOption) (openapi.Role, error)
- func (rc *RockClient) UpdateView(ctx context.Context, workspace, view, query string, ...) (openapi.View, 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
- func (rc *RockClient) WaitUntilViewGone(ctx context.Context, workspace, name string) error
- type RockConfig
- type RockOption
Examples ¶
Constants ¶
const APIKeyEnvironmentVariableName = "ROCKSET_APIKEY" //nolint
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.14.5"
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 ¶
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 ¶
NewError wraps err in an Error that provides better error messages than the openapi.GenericOpenAPIError
func (Error) IsNotFoundError ¶
IsNotFoundError returns true when the error is from an underlying 404 response from the Rockset REST API.
func (Error) RateLimited ¶
RateLimited checks if the error came from a http.StatusTooManyRequests, which is used for rate limiting.
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 WithXMLFormat ¶
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 PatchDocument ¶
type PatchDocument struct { ID string `json:"_id"` Patches []PatchOperation `json:"patch"` }
type PatchOperation ¶
type Querier ¶
type Querier interface {
Query(context.Context, string, ...option.QueryOption) (openapi.QueryResponse, error)
}
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 ¶
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.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, options ...option.APIKeyRoleOption) (openapi.ApiKey, error)
CreateAPIKey creates a new API key for the current user with the specified, with an optional role.
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) CreateAzureBlobStorageIntegration ¶
func (rc *RockClient) CreateAzureBlobStorageIntegration(ctx context.Context, name string, connection string) (openapi.Integration, error)
CreateAzureBlobStorageIntegration creates an integration for Azure's Blob Storage. requires a name for the integration and a connection string for the blob storage.
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, s3BucketName string, options ...option.DynamoDBIntegrationOption) (openapi.Integration, error)
CreateDynamoDBIntegration creates a new AWS DynamoDB integration. It requires AWS credentials using either option.AWSKeys() or option.AWSRole(), and an S3 bucket which is used to export the DynamoDB tables.
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) 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.
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.
func (*RockClient) CreateRole ¶
func (rc *RockClient) CreateRole(ctx context.Context, roleName string, options ...option.RoleOption) (openapi.Role, error)
CreateRole creates a new role
REST API documentation https://docs.rockset.com/rest-api/#createrole
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) CreateView ¶
func (rc *RockClient) CreateView(ctx context.Context, workspace, view, query string, options ...option.ViewOption) (openapi.View, error)
CreateView creates a new view, with an optional description.
REST API documentation https://docs.rockset.com/rest-api/#createview
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) 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.
func (*RockClient) DeleteQueryLambdaTag ¶
func (rc *RockClient) DeleteQueryLambdaTag(ctx context.Context, workspace, name, tag string) error
DeleteQueryLambdaTag deletes a query lambda tag.
func (*RockClient) DeleteQueryLambdaVersion ¶
func (rc *RockClient) DeleteQueryLambdaVersion(ctx context.Context, workspace, name, version string) error
DeleteQueryLambdaVersion deletes a query lambda version.
func (*RockClient) DeleteRole ¶
func (rc *RockClient) DeleteRole(ctx context.Context, roleName string) error
DeleteRole deletes a role.
REST API documentation https://docs.rockset.com/rest-api/#deleterole
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) DeleteView ¶
func (rc *RockClient) DeleteView(ctx context.Context, workspace, view string) error
DeleteView marks the view for deletion, which will take place in the background. Use the WaitUntilViewGone() call to block until the view has been deleted.
REST API documentation https://docs.rockset.com/rest-api/#deleteview
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 ¶
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 ¶
GetCurrentUser gets the current user.
REST API documentation https://docs.rockset.com/rest-api/#getcurrentuser
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) GetRole ¶
GetRole retrieve a role.
REST API documentation https://docs.rockset.com/rest-api/#getrole
func (*RockClient) GetView ¶
GetView gets details about a view.
REST API documentation https://docs.rockset.com/rest-api/#getview
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) ListIntegrations ¶
func (rc *RockClient) ListIntegrations(ctx context.Context) ([]openapi.Integration, error)
func (*RockClient) ListQueryLambdaTags ¶
func (rc *RockClient) ListQueryLambdaTags(ctx context.Context, workspace, queryLambda string) ([]openapi.QueryLambdaTag, error)
ListQueryLambdaTags lists all tags for a query lambda.
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.
func (*RockClient) ListRoles ¶
ListRoles list all roles.
REST API documentation https://docs.rockset.com/rest-api/#listroles
func (*RockClient) ListUsers ¶
ListUsers lists all users.
REST API documentation https://docs.rockset.com/rest-api/#listusers
func (*RockClient) ListViews ¶
func (rc *RockClient) ListViews(ctx context.Context, options ...option.ListViewOption) ([]openapi.View, error)
ListViews list views. Use option.WithViewWorkspace() to limit the request to just one workspace.
REST API documentation https://docs.rockset.com/rest-api/#listviews
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 ¶
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, 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 ¶
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 ¶
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.
func (*RockClient) UpdateRole ¶
func (rc *RockClient) UpdateRole(ctx context.Context, roleName string, options ...option.RoleOption) (openapi.Role, error)
UpdateRole updates a role.
REST API documentation https://docs.rockset.com/rest-api/#updaterole
func (*RockClient) UpdateView ¶
func (rc *RockClient) UpdateView(ctx context.Context, workspace, view, query string, options ...option.ViewOption) (openapi.View, error)
UpdateView updates an existing view, with an optional description.
REST API documentation https://docs.rockset.com/rest-api/#updateview
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 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.
func (*RockClient) WaitUntilViewGone ¶
func (rc *RockClient) WaitUntilViewGone(ctx context.Context, workspace, name string) error
WaitUntilViewGone waits until a view marked for deletion is gone, i.e. GetView() returns "not found".
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 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.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package option contains optional arguments for rockset.RockClient convenience methods.
|
Package option contains optional arguments for rockset.RockClient convenience methods. |