api

package
v1.0.0-beta.85 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HeaderRequestTimeout is an end-to-end request header that indicates the maximum time that a client is
	// prepared to await a response. The value of the header is in seconds. A client is allowed to send fractional
	// values. For ex, 0.1 means 100milliseconds.
	HeaderRequestTimeout = "Request-Timeout"

	HeaderAccept = "Accept"

	HeaderAccessControlAllowOrigin = "Access-Control-Allow-Origin"
	HeaderAuthorization            = "authorization"

	SetCookie = "Set-Cookie"
	Cookie    = "Cookie"

	HeaderPrefix = "Tigris-"

	HeaderTxID     = "Tigris-Tx-Id"
	HeaderTxOrigin = "Tigris-Tx-Origin"

	HeaderSchemaSignOff             = "Tigris-Schema-Sign-Off"
	HeaderBypassAuthCache           = "Tigris-Bypass-Auth-Cache" // #nosec G101
	HeaderReadSearchDataFromStorage = "Tigris-Search-Read-From-Storage"
)
View Source
const (
	ManagementMethodPrefix    = "/tigrisdata.management.v1.Management/"
	ObservabilityMethodPrefix = "/tigrisdata.observability.v1.Observability/"

	BeginTransactionMethodName    = apiMethodPrefix + "BeginTransaction"
	CommitTransactionMethodName   = apiMethodPrefix + "CommitTransaction"
	RollbackTransactionMethodName = apiMethodPrefix + "RollbackTransaction"

	InsertMethodName  = apiMethodPrefix + "Insert"
	ReplaceMethodName = apiMethodPrefix + "Replace"
	DeleteMethodName  = apiMethodPrefix + "Delete"
	UpdateMethodName  = apiMethodPrefix + "Update"
	ReadMethodName    = apiMethodPrefix + "Read"
	CountMethodName   = apiMethodPrefix + "Count"

	BuildCollectionIndexMethodName = apiMethodPrefix + "BuildCollectionIndex"
	ExplainMethodName              = apiMethodPrefix + "Explain"

	SearchMethodName = apiMethodPrefix + "Search"
	ImportMethodName = apiMethodPrefix + "Import"

	IndexCollection                 = apiMethodPrefix + "IndexCollection"
	SearchIndexCollectionMethodName = apiMethodPrefix + "BuildSearchIndex"

	CreateOrUpdateCollectionMethodName  = apiMethodPrefix + "CreateOrUpdateCollection"
	CreateOrUpdateCollectionsMethodName = apiMethodPrefix + "CreateOrUpdateCollections"

	DropCollectionMethodName = apiMethodPrefix + "DropCollection"

	ListProjectsMethodName    = apiMethodPrefix + "ListProjects"
	ListCollectionsMethodName = apiMethodPrefix + "ListCollections"
	CreateProjectMethodName   = apiMethodPrefix + "CreateProject"

	DeleteProjectMethodName      = apiMethodPrefix + "DeleteProject"
	DescribeDatabaseMethodName   = apiMethodPrefix + "DescribeDatabase"
	DescribeCollectionMethodName = apiMethodPrefix + "DescribeCollection"

	CreateBranchMethodName = apiMethodPrefix + "CreateBranch"
	DeleteBranchMethodName = apiMethodPrefix + "DeleteBranch"
	ListBranchesMethodName = apiMethodPrefix + "ListBranches"

	CreateAppKeyMethodName       = apiMethodPrefix + "CreateAppKey"
	UpdateAppKeyMethodName       = apiMethodPrefix + "UpdateAppKey"
	DeleteAppKeyMethodName       = apiMethodPrefix + "DeleteAppKey"
	ListAppKeysMethodName        = apiMethodPrefix + "ListAppKeys"
	RotateAppKeySecretMethodName = apiMethodPrefix + "RotateAppKeySecret"

	CreateGlobalAppKeyMethodName       = apiMethodPrefix + "CreateGlobalAppKey"
	UpdateGlobalAppKeyMethodName       = apiMethodPrefix + "UpdateGlobalAppKey"
	DeleteGlobalAppKeyMethodName       = apiMethodPrefix + "DeleteGlobalAppKey"
	ListGlobalAppKeysMethodName        = apiMethodPrefix + "ListGlobalAppKeys"
	RotateGlobalAppKeySecretMethodName = apiMethodPrefix + "RotateGlobalAppKeySecret"

	// Auth.
	GetAccessTokenMethodName    = authMethodPrefix + "GetAccessToken"
	CreateInvitationsMethodName = authMethodPrefix + "CreateInvitations"
	DeleteInvitationsMethodName = authMethodPrefix + "DeleteInvitations"
	ListInvitationsMethodName   = authMethodPrefix + "ListInvitations"
	VerifyInvitationMethodName  = authMethodPrefix + "VerifyInvitation"
	ListUsersMethodName         = authMethodPrefix + "ListUsers"

	// Billing.
	ListInvoicesMethodName = billingMethodPrefix + "ListInvoices"

	// Cache.
	CreateCacheMethodName = cacheMethodPrefix + "CreateCache"
	ListCachesMethodName  = cacheMethodPrefix + "ListCaches"
	DeleteCacheMethodName = cacheMethodPrefix + "DeleteCache"
	SetMethodName         = cacheMethodPrefix + "Set"
	GetSetMethodName      = cacheMethodPrefix + "GetSet"
	GetMethodName         = cacheMethodPrefix + "Get"
	DelMethodName         = cacheMethodPrefix + "Del"
	KeysMethodName        = cacheMethodPrefix + "Keys"

	// Health.
	HealthMethodName = "/HealthAPI/Health"

	// Management.
	CreateNamespaceMethodName         = ManagementMethodPrefix + "CreateNamespace"
	ListNamespacesMethodName          = ManagementMethodPrefix + "ListNamespaces"
	DeleteNamespaceMethodName         = ManagementMethodPrefix + "DeleteNamespace"
	InsertUserMetadataMethodName      = ManagementMethodPrefix + "InsertUserMetadata"
	GetUserMetadataMethodName         = ManagementMethodPrefix + "GetUserMetadata"
	UpdateUserMetadataMethodName      = ManagementMethodPrefix + "UpdateUserMetadata"
	InsertNamespaceMetadataMethodName = ManagementMethodPrefix + "InsertNamespaceMetadata"
	GetNamespaceMetadataMethodName    = ManagementMethodPrefix + "GetNamespaceMetadata"
	UpdateNamespaceMetadataMethodName = ManagementMethodPrefix + "UpdateNamespaceMetadata"

	// Observability.
	QueryTimeSeriesMetricsMethodName = ObservabilityMethodPrefix + "QueryTimeSeriesMetrics"
	QuotaLimitsMetricsMethodName     = ObservabilityMethodPrefix + "QuotaLimits"

	// Realtime.
	PresenceMethodName          = realtimeMethodPrefix + "Presence"
	GetRTChannelMethodName      = realtimeMethodPrefix + "GetRTChannel"
	GetRTChannelsMethodName     = realtimeMethodPrefix + "GetRTChannels"
	ReadMessagesMethodName      = realtimeMethodPrefix + "ReadMessages"
	MessagesMethodName          = realtimeMethodPrefix + "Messages"
	ListSubscriptionsMethodName = realtimeMethodPrefix + "ListSubscriptions"
)
View Source
const CollationKey string = "collation"

Variables

View Source
var SupportedCollations = [...]string{
	CaseInsensitive:  "ci",
	CaseSensitive:    "cs",
	CollationSortKey: "csk",
}

Functions

func CodeToString

func CodeToString(c Code) string

CodeToString convert Tigris error code into string representation.

func CustomMatcher

func CustomMatcher(key string) (string, bool)

func GetHeader

func GetHeader(ctx context.Context, header string) string

func GetNonGRPCGatewayHeader

func GetNonGRPCGatewayHeader(ctx context.Context, header string) string

func IsTxSupported

func IsTxSupported(ctx context.Context) bool

func MarshalStatus

func MarshalStatus(status *spb.Status) ([]byte, error)

MarshalStatus marshal status object.

func RawMessageToByte

func RawMessageToByte(arr []jsoniter.RawMessage) [][]byte

func ToGRPCCode

func ToGRPCCode(code Code) codes.Code

ToGRPCCode converts Tigris error code to GRPC code Extended codes converted to 'Unknown' GRPC code.

func ToHTTPCode

func ToHTTPCode(code Code) int

ToHTTPCode converts Tigris' code to HTTP status code Used to customize HTTP codes returned by GRPC-gateway.

Types

type CollationType

type CollationType uint8
const (
	Undefined CollationType = iota
	CaseInsensitive
	CaseSensitive
	CollationSortKey
)

func ToCollationType

func ToCollationType(userCollation string) CollationType

type CustomDecoder

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

func (CustomDecoder) Decode

func (f CustomDecoder) Decode(dst any) error

type CustomMarshaler

type CustomMarshaler struct {
	JSONBuiltin *runtime.JSONBuiltin
}

CustomMarshaler is a marshaler to customize the response. Currently, it is only used to marshal custom error message otherwise it just uses the inbuilt mux marshaller.

func (*CustomMarshaler) ContentType

func (c *CustomMarshaler) ContentType(v any) string

func (*CustomMarshaler) Marshal

func (c *CustomMarshaler) Marshal(v any) ([]byte, error)

func (*CustomMarshaler) NewDecoder

func (*CustomMarshaler) NewDecoder(r io.Reader) runtime.Decoder

func (*CustomMarshaler) NewEncoder

func (c *CustomMarshaler) NewEncoder(w io.Writer) runtime.Encoder

func (*CustomMarshaler) Unmarshal

func (c *CustomMarshaler) Unmarshal(data []byte, v any) error

type Metadata

type Metadata struct {
	CreatedAt *time.Time `json:"created_at,omitempty"`
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
	DeletedAt *time.Time `json:"deleted_at,omitempty"`
}

func CreateMDFromResponseMD

func CreateMDFromResponseMD(x *ResponseMetadata) Metadata

type Request

type Request interface {
	proto.Message

	Validator
}

type RequestWithProject

type RequestWithProject interface {
	GetProject() string
	GetBranch() string
}

type RequestWithProjectAndCollection

type RequestWithProjectAndCollection interface {
	GetProject() string
	GetCollection() string
	GetBranch() string
}

type Response

type Response interface {
	proto.Message
}

type SearchHitMetadata

type SearchHitMetadata struct {
	CreatedAt *time.Time `json:"created_at,omitempty"`
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
	Match     *Match     `json:"match,omitempty"`
}

func CreateMDFromSearchMD

func CreateMDFromSearchMD(x *SearchHitMeta) *SearchHitMetadata

type TigrisError

type TigrisError struct {
	// Contains Tigris extended error code.
	// Codes upto Code_UNAUTHENTICATED are identical to GRPC error codes
	Code Code `json:"code,omitempty"`
	// A developer-facing error message.
	Message string `json:"message,omitempty"`

	// Contains extended error information.
	// For example retry information.
	Details []proto.Message `json:"details,omitempty"`
}

TigrisError is our Tigris HTTP counterpart of grpc status. All the APIs should use this Error to return as a user facing error. TigrisError will return grpcStatus to the muxer so that grpc client can see grpcStatus as the final output. For HTTP clients see the **MarshalStatus** method where we are returning the response by not the grpc code as that is not needed for HTTP clients.

func Errorf

func Errorf(c Code, format string, a ...any) *TigrisError

Errorf constructs TigrisError. This is the only error server code should return.

func FromErrorDetails

func FromErrorDetails(e *ErrorDetails) *TigrisError

FromErrorDetails construct TigrisError from the ErrorDetails, which contains extended code, retry information, etc...

func FromStatusError

func FromStatusError(err error) *TigrisError

FromStatusError parses GRPC status from error into TigrisError. This is used by the client code.

func UnmarshalStatus

func UnmarshalStatus(b []byte) *TigrisError

UnmarshalStatus reconstruct TigrisError from HTTP error JSON body. This is used by the client.

func (*TigrisError) As

func (e *TigrisError) As(i any) bool

As is used by runtime.DefaultHTTPErrorHandler to override HTTP status code.

func (*TigrisError) Error

func (e *TigrisError) Error() string

Error to return the underlying error message.

func (*TigrisError) GRPCStatus

func (e *TigrisError) GRPCStatus() *status.Status

GRPCStatus converts the TigrisError and return status.Status. This is used to return grpc status to the grpc clients.

func (*TigrisError) RetryDelay

func (e *TigrisError) RetryDelay() time.Duration

RetryDelay retrieves retry delay if it's attached to the error.

func (*TigrisError) WithDetails

func (e *TigrisError) WithDetails(details ...proto.Message) *TigrisError

WithDetails a helper method for adding details to the TigrisError.

func (*TigrisError) WithRetry

func (e *TigrisError) WithRetry(d time.Duration) *TigrisError

WithRetry attached retry information to the error.

type Validator

type Validator interface {
	Validate() error
}

Jump to

Keyboard shortcuts

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