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 Collections
- 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 ¶
type AuthMethod struct { AuthProviders []AuthProvider `json:"authProviders"` UsernamePassword bool `json:"usernamePassword"` EmailPassword bool `json:"emailPassword"` OnlyVerified bool `json:"onlyVerified"` }
type AuthProvider ¶
type AuthRefreshResponse ¶
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 ¶
type AuthWithOauth2Response struct {
Token string `json:"token"`
}
type Backup ¶
type Backup struct {
*Client
}
func (Backup) Delete ¶
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 ¶
func (b Backup) FullList() ([]ResponseBackupFullList, error)
FullList returns list with all available backup files.
func (Backup) GetDownloadURL ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
func (c *Collection[T]) ConfirmEmailChange(emailChangeToken string, password string) error
ConfirmEmailChange confirms auth record's new email address.
func (*Collection[T]) ConfirmPasswordReset ¶
func (c *Collection[T]) ConfirmPasswordReset(passwordResetToken string, password string, passwordConfirm string) error
ConfirmPasswordReset confirms auth record password reset request.
func (*Collection[T]) ConfirmVerification ¶
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 ¶
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 ¶
func (c *Collection[T]) ListAuthMethods() (AuthMethod, error)
ListAuthMethods returns all available collection auth methods.
func (*Collection[T]) ListExternalAuths ¶
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 ¶
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 ¶
func (c *Collection[T]) RequestEmailChange(newEmail string) error
RequestEmailChange sends an email change request to the authenticated record model.
func (*Collection[T]) RequestPasswordReset ¶
func (c *Collection[T]) RequestPasswordReset(email string) error
RequestPasswordReset sends auth record password reset request
func (*Collection[T]) RequestVerification ¶
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 ¶
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 Collections ¶
func NewCollections ¶
func NewCollections(client *Client) *Collections
func (*Collections) List ¶
func (c *Collections) List(params ParamsList) (ResponseList[models.Collection], error)
type CreateRequest ¶
type CreateRequest struct {
Name string `json:"name"`
}
type ExternalAuthRequest ¶
type ParamsList ¶
type Record ¶
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 ¶
type ResponseCreate ¶
type ResponseGetToken ¶
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
}