Documentation ¶
Index ¶
- Variables
- type AuthMethod
- type AuthProvider
- type AuthRefreshResponse
- type AuthWithOauth2Response
- type AuthWithPasswordResponse
- type Backup
- func (b Backup) Create(key ...string) error
- func (b Backup) Delete(key string) error
- func (b Backup) FullList() ([]ResponseBackupFullList, error)
- func (b Backup) GetDownloadURL(token string, key string) (string, error)
- func (b Backup) Restore(key string) error
- func (b Backup) Upload(key string, reader io.Reader) error
- type Client
- func (c *Client) AuthStore() authStore
- func (c *Client) Authorize() error
- func (c *Client) Backup() Backup
- func (c *Client) Create(collection string, body any) (ResponseCreate, error)
- func (c *Client) Delete(collection string, id string) error
- func (c *Client) Files() Files
- func (c *Client) FullList(collection string, params ParamsList) (ResponseList[map[string]any], error)
- func (c *Client) List(collection string, params ParamsList) (ResponseList[map[string]any], error)
- func (c *Client) One(collection string, id string) (map[string]any, error)
- func (c *Client) OneTo(collection string, id string, result any) error
- func (c *Client) Update(collection string, id string, body any) error
- type ClientOption
- func WithAdminEmailPassword(email, password string) ClientOption
- func WithAdminToken(token string) ClientOption
- func WithDebug() ClientOption
- func WithUserEmailPassword(email, password string) ClientOption
- func WithUserEmailPasswordAndCollection(email, password, collection string) ClientOption
- func WithUserToken(token string) ClientOption
- type Collection
- func (c *Collection[T]) AuthRefresh() (AuthRefreshResponse, error)
- func (c *Collection[T]) AuthWithOAuth2Code(provider string, code string, codeVerifier string, redirectURL string) (AuthWithOauth2Response, error)
- func (c *Collection[T]) AuthWithPassword(username string, password string) (AuthWithPasswordResponse, error)
- func (c *Collection[T]) ConfirmEmailChange(emailChangeToken string, password string) error
- func (c *Collection[T]) ConfirmPasswordReset(passwordResetToken string, password string, passwordConfirm string) error
- func (c *Collection[T]) ConfirmVerification(verificationToken string) error
- func (c *Collection[T]) Create(body T) (ResponseCreate, error)
- func (c *Collection[T]) Delete(id string) error
- func (c *Collection[T]) FullList(params ParamsList) (ResponseList[T], error)
- func (c *Collection[T]) List(params ParamsList) (ResponseList[T], error)
- func (c *Collection[T]) ListAuthMethods() (AuthMethod, error)
- func (c *Collection[T]) ListExternalAuths(recordID string) ([]ExternalAuthRequest, error)
- func (c *Collection[T]) One(id string) (T, error)
- func (c *Collection[T]) OneWithParams(id string, params ParamsList) (T, error)
- func (c *Collection[T]) RequestEmailChange(newEmail string) error
- func (c *Collection[T]) RequestPasswordReset(email string) error
- func (c *Collection[T]) RequestVerification(email string) error
- func (c *Collection[T]) Subscribe(targets ...string) (*Stream[T], error)
- func (c *Collection[T]) SubscribeWith(opts SubscribeOptions, targets ...string) (*Stream[T], error)
- func (c *Collection[T]) UnlinkExternalAuth(recordID string, provider string) error
- func (c *Collection[T]) Update(id string, body T) error
- type CreateRequest
- type Event
- type ExternalAuthRequest
- type Files
- type ParamsList
- type Record
- type ResponseBackupFullList
- type ResponseCreate
- type ResponseGetToken
- type ResponseList
- type Stream
- type SubscribeOptions
- type SubscriptionsSet
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidResponse = errors.New("invalid response")
Functions ¶
This section is empty.
Types ¶
type AuthMethod ¶ added in v0.0.10
type AuthMethod struct { AuthProviders []AuthProvider `json:"authProviders"` UsernamePassword bool `json:"usernamePassword"` EmailPassword bool `json:"emailPassword"` OnlyVerified bool `json:"onlyVerified"` }
type AuthProvider ¶ added in v0.0.10
type AuthRefreshResponse ¶ added in v0.0.10
type AuthRefreshResponse struct { Record struct { Avatar string `json:"avatar"` CollectionID string `json:"collectionId"` CollectionName string `json:"collectionName"` Created string `json:"created"` Email string `json:"email"` EmailVisibility bool `json:"emailVisibility"` ID string `json:"id"` Name string `json:"name"` Updated string `json:"updated"` Username string `json:"username"` Verified bool `json:"verified"` } `json:"record"` Token string `json:"token"` }
type AuthWithOauth2Response ¶ added in v0.0.10
type AuthWithOauth2Response struct {
Token string `json:"token"`
}
type AuthWithPasswordResponse ¶ added in v0.0.10
type Backup ¶ added in v0.0.9
type Backup struct {
*Client
}
func (Backup) Delete ¶ added in v0.0.9
Delete deletes a single backup file.
Example:
file, _ := os.Open("./backups/pb_backup.zip") defer file.Close() _ = defaultClient.Backup().Upload("mybackup.zip", file)
func (Backup) FullList ¶ added in v0.0.9
func (b Backup) FullList() ([]ResponseBackupFullList, error)
FullList returns list with all available backup files.
func (Backup) GetDownloadURL ¶ added in v0.0.9
GetDownloadToken builds a download url for a single existing backup using an admin file token and the backup file key.
The file token can be generated via `client.Files().GetToken()`.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(url string, opts ...ClientOption) *Client
func (*Client) Create ¶
func (c *Client) Create(collection string, body any) (ResponseCreate, error)
func (*Client) FullList ¶ added in v0.0.7
func (c *Client) FullList(collection string, params ParamsList) (ResponseList[map[string]any], error)
func (*Client) List ¶
func (c *Client) List(collection string, params ParamsList) (ResponseList[map[string]any], error)
type ClientOption ¶
type ClientOption func(*Client)
func WithAdminEmailPassword ¶
func WithAdminEmailPassword(email, password string) ClientOption
func WithAdminToken ¶
func WithAdminToken(token string) ClientOption
func WithDebug ¶
func WithDebug() ClientOption
func WithUserEmailPassword ¶
func WithUserEmailPassword(email, password string) ClientOption
func WithUserEmailPasswordAndCollection ¶ added in v0.0.8
func WithUserEmailPasswordAndCollection(email, password, collection string) ClientOption
func WithUserToken ¶
func WithUserToken(token string) ClientOption
type Collection ¶
func CollectionSet ¶
func CollectionSet[T any](client *Client, collection string) *Collection[T]
func (*Collection[T]) AuthRefresh ¶ added in v0.0.10
func (c *Collection[T]) AuthRefresh() (AuthRefreshResponse, error)
AuthRefresh refreshes the current authenticated record instance and * returns a new token and record data.
func (*Collection[T]) AuthWithOAuth2Code ¶ added in v0.0.10
func (c *Collection[T]) AuthWithOAuth2Code(provider string, code string, codeVerifier string, redirectURL string) (AuthWithOauth2Response, error)
AuthWithOAuth2Code authenticate a single auth collection record with OAuth2 code.
If you don't have an OAuth2 code you may also want to check `authWithOAuth2` method.
On success, this method also automatically updates the client's AuthStore data and returns: - the authentication token via the model - the authenticated record model - the OAuth2 account data (eg. name, email, avatar, etc.)
func (*Collection[T]) AuthWithPassword ¶ added in v0.0.10
func (c *Collection[T]) AuthWithPassword(username string, password string) (AuthWithPasswordResponse, error)
AuthWithPassword authenticate a single auth collection record via its username/email and password.
On success, this method also automatically updates the client's AuthStore data and returns: - the authentication token via the AuthWithPasswordResponse - the authenticated record model
func (*Collection[T]) ConfirmEmailChange ¶ added in v0.0.10
func (c *Collection[T]) ConfirmEmailChange(emailChangeToken string, password string) error
ConfirmEmailChange confirms auth record's new email address.
func (*Collection[T]) ConfirmPasswordReset ¶ added in v0.0.10
func (c *Collection[T]) ConfirmPasswordReset(passwordResetToken string, password string, passwordConfirm string) error
ConfirmPasswordReset confirms auth record password reset request.
func (*Collection[T]) ConfirmVerification ¶ added in v0.0.10
func (c *Collection[T]) ConfirmVerification(verificationToken string) error
ConfirmVerification confirms auth record email verification request.
If the current `client.authStore.model` matches with the auth record from the token, then on success the `client.authStore.model.verified` will be updated to `true`.
func (*Collection[T]) Create ¶
func (c *Collection[T]) Create(body T) (ResponseCreate, error)
func (*Collection[T]) Delete ¶
func (c *Collection[T]) Delete(id string) error
func (*Collection[T]) FullList ¶ added in v0.0.7
func (c *Collection[T]) FullList(params ParamsList) (ResponseList[T], error)
func (*Collection[T]) List ¶
func (c *Collection[T]) List(params ParamsList) (ResponseList[T], error)
func (*Collection[T]) ListAuthMethods ¶ added in v0.0.10
func (c *Collection[T]) ListAuthMethods() (AuthMethod, error)
ListAuthMethods returns all available collection auth methods.
func (*Collection[T]) ListExternalAuths ¶ added in v0.0.10
func (c *Collection[T]) ListExternalAuths(recordID string) ([]ExternalAuthRequest, error)
ListExternalAuths lists all linked external auth providers for the specified auth record.
func (*Collection[T]) One ¶
func (c *Collection[T]) One(id string) (T, error)
func (*Collection[T]) OneWithParams ¶ added in v0.0.6
func (c *Collection[T]) OneWithParams(id string, params ParamsList) (T, error)
Get one record with params (only fields and expand supported)
func (*Collection[T]) RequestEmailChange ¶ added in v0.0.10
func (c *Collection[T]) RequestEmailChange(newEmail string) error
RequestEmailChange sends an email change request to the authenticated record model.
func (*Collection[T]) RequestPasswordReset ¶ added in v0.0.10
func (c *Collection[T]) RequestPasswordReset(email string) error
RequestPasswordReset sends auth record password reset request
func (*Collection[T]) RequestVerification ¶ added in v0.0.10
func (c *Collection[T]) RequestVerification(email string) error
RequestVerification sends auth record verification email request.
func (*Collection[T]) Subscribe ¶
func (c *Collection[T]) Subscribe(targets ...string) (*Stream[T], error)
func (*Collection[T]) SubscribeWith ¶
func (c *Collection[T]) SubscribeWith(opts SubscribeOptions, targets ...string) (*Stream[T], error)
func (*Collection[T]) UnlinkExternalAuth ¶ added in v0.0.10
func (c *Collection[T]) UnlinkExternalAuth(recordID string, provider string) error
UnlinkExternalAuth unlink a single external auth provider from the specified auth record.
func (*Collection[T]) Update ¶
func (c *Collection[T]) Update(id string, body T) error
type CreateRequest ¶ added in v0.0.9
type CreateRequest struct {
Name string `json:"name"`
}
type ExternalAuthRequest ¶ added in v0.0.10
type ParamsList ¶
type Record ¶ added in v0.0.10
type Record struct { Avatar string `json:"avatar"` CollectionID string `json:"collectionId"` CollectionName string `json:"collectionName"` Created string `json:"created"` Email string `json:"email"` EmailVisibility bool `json:"emailVisibility"` ID string `json:"id"` Name string `json:"name"` Updated string `json:"updated"` Username string `json:"username"` Verified bool `json:"verified"` }
type ResponseBackupFullList ¶ added in v0.0.9
type ResponseCreate ¶
type ResponseGetToken ¶ added in v0.0.9
type ResponseGetToken struct {
Token string `json:"token"`
}
type ResponseList ¶
type Stream ¶
type Stream[T any] struct { // contains filtered or unexported fields }
func (*Stream[T]) Unsubscribe ¶
func (s *Stream[T]) Unsubscribe()
func (*Stream[T]) WaitAuthReady
deprecated
type SubscribeOptions ¶
type SubscribeOptions struct {
ReconnectStrategy backoff.BackOff
}