Documentation ¶
Overview ¶
Package types provides the types used in the Yorkie API. This package is used by both the server and the client.
Index ¶
- Constants
- Variables
- func GetChangesRange(paging Paging[int64], lastSeq int64) (int64, int64)
- func IsAuthMethod(method string) bool
- type AccessAttribute
- type AccessInfo
- type AuthWebhookRequest
- type AuthWebhookResponse
- type ChangeSummary
- type ClientRefKey
- type CreateProjectFields
- type DocEventBody
- type DocEventType
- type DocRefKey
- type DocumentSummary
- type ID
- type Method
- type Paging
- type Project
- type SearchResult
- type SnapshotRefKey
- type SyncMode
- type UpdatableProjectFields
- type User
- type UserFields
- type VerbType
- type VersionDetail
- type VersionInfo
Constants ¶
const APIKeyKey = "x-api-key"
APIKeyKey is the key of the api key header.
const AuthorizationKey = "authorization"
AuthorizationKey is the key of the authorization header.
const GoSDKType = "yorkie-go-sdk"
GoSDKType is the type part of Go SDK in value of UserAgent.
const ShardKey = "x-shard-key"
ShardKey is the key of the shard header.
const UserAgentKey = "x-yorkie-user-agent"
UserAgentKey is the key of the user agent header.
Variables ¶
var ( // ErrInvalidWebhookRequest is returned when the given webhook request is not valid. ErrInvalidWebhookRequest = errors.New("invalid authorization webhook request") // ErrInvalidWebhookResponse is returned when the given webhook response is not valid. ErrInvalidWebhookResponse = errors.New("invalid authorization webhook response") )
var ErrEmptyProjectFields = errors.New("updatable project fields are empty")
ErrEmptyProjectFields is returned when all the fields are empty.
var ( // ErrInvalidID is returned when the given ID is not ObjectID. ErrInvalidID = errors.New("invalid ID") )
Functions ¶
func GetChangesRange ¶ added in v0.2.11
GetChangesRange returns a range of changes.
func IsAuthMethod ¶
IsAuthMethod returns whether the given method can be used for authorization.
Types ¶
type AccessAttribute ¶
AccessAttribute represents an access attribute.
func NewAccessAttributes ¶ added in v0.3.0
func NewAccessAttributes(docKeys []key.Key, verb VerbType) []AccessAttribute
NewAccessAttributes creates a new instance of AccessAttributes.
type AccessInfo ¶
type AccessInfo struct { Method Method Attributes []AccessAttribute }
AccessInfo represents an access information.
type AuthWebhookRequest ¶
type AuthWebhookRequest struct { Token string `json:"token"` Method Method `json:"method"` Attributes []AccessAttribute `json:"attributes"` }
AuthWebhookRequest represents the request of authentication webhook.
func NewAuthWebhookRequest ¶
func NewAuthWebhookRequest(reader io.Reader) (*AuthWebhookRequest, error)
NewAuthWebhookRequest creates a new instance of AuthWebhookRequest.
type AuthWebhookResponse ¶
AuthWebhookResponse represents the response of authentication webhook.
func NewAuthWebhookResponse ¶
func NewAuthWebhookResponse(reader io.Reader) (*AuthWebhookResponse, error)
NewAuthWebhookResponse creates a new instance of AuthWebhookResponse.
type ChangeSummary ¶
type ChangeSummary struct { // ID is the unique identifier of the change. ID change.ID // Message is the message of the change. Message string // Snapshot is the snapshot of the document. Snapshot string }
ChangeSummary represents a summary of change.
type ClientRefKey ¶ added in v0.4.14
ClientRefKey represents an identifier used to reference a client.
func (ClientRefKey) String ¶ added in v0.4.14
func (r ClientRefKey) String() string
String returns the string representation of the given ClientRefKey.
type CreateProjectFields ¶ added in v0.2.18
type CreateProjectFields struct { // Name is the name of this project. Name *string `bson:"name,omitempty" validate:"required,min=2,max=30,slug,reserved_project_name"` }
CreateProjectFields is a set of fields that use to create a project.
func (*CreateProjectFields) Validate ¶ added in v0.2.18
func (i *CreateProjectFields) Validate() error
Validate validates the CreateProjectFields.
type DocEventBody ¶ added in v0.4.7
DocEventBody includes additional data specific to the DocEvent.
func (*DocEventBody) PayloadLen ¶ added in v0.5.1
func (b *DocEventBody) PayloadLen() int
PayloadLen returns the size of the payload.
type DocEventType ¶
type DocEventType string
DocEventType represents the event that the Server delivers to the client.
const ( // DocumentChangedEvent is an event indicating that document is being // modified by a change. DocumentChangedEvent DocEventType = "document-changed" // DocumentWatchedEvent is an event that occurs when document is watched // by other clients. DocumentWatchedEvent DocEventType = "document-watched" // DocumentUnwatchedEvent is an event that occurs when document is // unwatched by other clients. DocumentUnwatchedEvent DocEventType = "document-unwatched" // DocumentBroadcastEvent is an event that occurs when a payload is broadcasted // on a specific topic. DocumentBroadcastEvent DocEventType = "document-broadcast" )
type DocumentSummary ¶
type DocumentSummary struct { // ID is the unique identifier of the document. ID ID // Key is the key of the document. Key key.Key // CreatedAt is the time when the document is created. CreatedAt time.Time // AccessedAt is the time when the document is accessed. AccessedAt time.Time // UpdatedAt is the time when the document is updated. UpdatedAt time.Time // Snapshot is the string representation of the document. Snapshot string }
DocumentSummary represents a summary of document.
type ID ¶
type ID string
ID represents ID of entity.
func IDFromActorID ¶
IDFromActorID returns ID represented by the encoded hexadecimal string from actor ID.
func IDFromBytes ¶
IDFromBytes returns ID represented by the encoded hexadecimal string from bytes.
type Method ¶
type Method string
Method represents a method name of RPC.
const ( ActivateClient Method = "ActivateClient" DeactivateClient Method = "DeactivateClient" AttachDocument Method = "AttachDocument" DetachDocument Method = "DetachDocument" RemoveDocument Method = "RemoveDocument" PushPull Method = "PushPull" WatchDocuments Method = "WatchDocuments" Broadcast Method = "Broadcast" )
Belows are the names of RPCs.
func AuthMethods ¶
func AuthMethods() []Method
AuthMethods returns a slice of methods that can be used for authorization.
type Project ¶
type Project struct { // ID is the unique ID of the project. ID ID `json:"id"` // Name is the name of this project. Name string `json:"name"` // Owner is the owner of this project. Owner ID `json:"owner"` // AuthWebhookURL is the url of the authorization webhook. AuthWebhookURL string `json:"auth_webhook_url"` // AuthWebhookMethods is the methods that run the authorization webhook. AuthWebhookMethods []string `json:"auth_webhook_methods"` // ClientDeactivateThreshold is the time after which clients in // specific project are considered deactivate for housekeeping. ClientDeactivateThreshold string `bson:"client_deactivate_threshold"` // PublicKey is the API key of this project. PublicKey string `json:"public_key"` // SecretKey is the secret key of this project. SecretKey string `json:"secret_key"` // CreatedAt is the time when the project was created. CreatedAt time.Time `json:"created_at"` // UpdatedAt is the time when the project was updated. UpdatedAt time.Time `json:"updated_at"` }
Project is a project that consists of multiple documents and clients.
func (*Project) RequireAuth ¶
RequireAuth returns whether the given method requires authorization.
type SearchResult ¶ added in v0.2.13
type SearchResult[T any] struct { // TotalCount is the total count of the elements. TotalCount int // Elements is a list of elements. Elements []T }
SearchResult is a result of search.
type SnapshotRefKey ¶ added in v0.4.14
SnapshotRefKey represents an identifier used to reference a snapshot.
func (SnapshotRefKey) String ¶ added in v0.4.14
func (r SnapshotRefKey) String() string
String returns the string representation of the given SnapshotRefKey.
type SyncMode ¶ added in v0.3.4
type SyncMode int
SyncMode is the mode of synchronization. It is used to determine whether to push and pull changes in PushPullChanges API.
type UpdatableProjectFields ¶ added in v0.2.8
type UpdatableProjectFields struct { // Name is the name of this project. Name *string `bson:"name,omitempty" validate:"omitempty,min=2,max=30,slug,reserved_project_name"` // AuthWebhookURL is the url of the authorization webhook. AuthWebhookURL *string `bson:"auth_webhook_url,omitempty" validate:"omitempty,url|emptystring"` // AuthWebhookMethods is the methods that run the authorization webhook. AuthWebhookMethods *[]string `bson:"auth_webhook_methods,omitempty" validate:"omitempty,invalid_webhook_method"` // ClientDeactivateThreshold is the time after which clients in specific project are considered deactivate. ClientDeactivateThreshold *string `bson:"client_deactivate_threshold,omitempty" validate:"omitempty,min=2,duration"` }
UpdatableProjectFields is a set of fields that use to update a project.
func (*UpdatableProjectFields) Validate ¶ added in v0.2.8
func (i *UpdatableProjectFields) Validate() error
Validate validates the UpdatableProjectFields.
type User ¶ added in v0.2.14
type User struct { // ID is the unique ID of the user. ID ID `json:"id"` // Username is the username of the user. Username string `json:"username"` // CreatedAt is the time when the user was created. CreatedAt time.Time `json:"created_at"` }
User is a user that can access the project.
type UserFields ¶ added in v0.4.29
type UserFields struct { // Username is the name of user. Username *string `bson:"username" validate:"required,min=2,max=30,slug"` // Password is the password of user. Password *string `bson:"password" validate:"required,min=8,max=30,alpha_num_special"` }
UserFields is a set of fields that use to sign up or change password to yorkie server.
func (*UserFields) Validate ¶ added in v0.4.29
func (i *UserFields) Validate() error
Validate validates the UserFields.
type VersionDetail ¶ added in v0.4.30
type VersionDetail struct { // YorkieVersion YorkieVersion string `json:"yorkieVersion" yaml:"yorkieVersion"` // GoVersion GoVersion string `json:"goVersion" yaml:"goVersion"` // BuildDate BuildDate string `json:"buildDate" yaml:"buildDate"` }
VersionDetail represents detail information of version.
type VersionInfo ¶ added in v0.4.30
type VersionInfo struct { // ClientVersion is the yorkie cli version. ClientVersion *VersionDetail `json:"clientVersion,omitempty" yaml:"clientVersion,omitempty"` // ServerVersion is the yorkie server version. ServerVersion *VersionDetail `json:"serverVersion,omitempty" yaml:"serverVersion,omitempty"` }
VersionInfo represents information of version.