client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: Apache-2.0 Imports: 18 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	MaxPageSize = 250
	MinPageSize = 10
)

Variables

View Source
var ErrUserAlreadyExists = errors.New("user already exists")

ErrUserAlreadyExists is the idempotent-create sentinel the lifecycle handlers tolerate.

View Source
var ErrUserNotFound = errors.New("user not found")

ErrUserNotFound is returned by GetUserSID when no user row matches the legacy id.

Functions

This section is empty.

Types

type Client

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

func New

func New(ctx context.Context, dsn string, apiBaseURL string, apiToken string) (*Client, error)

func (*Client) AddGroupMember

func (c *Client) AddGroupMember(ctx context.Context, groupID, userID int64, isAdmin bool) error

func (*Client) CreateGroup

func (c *Client) CreateGroup(ctx context.Context, organizationID *int64, name string) error

func (*Client) CreateUser

func (c *Client) CreateUser(ctx context.Context, params CreateUserParams) (*RESTUser, annotations.Annotations, error)

CreateUser provisions a new Retool user. Returns ErrUserAlreadyExists on a duplicate email (HTTP 409) so the caller can resolve and return the existing account.

func (*Client) DeleteGroupPage

func (c *Client) DeleteGroupPage(ctx context.Context, id int64) error

func (*Client) GetGroup

func (c *Client) GetGroup(ctx context.Context, groupID int64) (*GroupModel, error)

func (*Client) GetGroupByName

func (c *Client) GetGroupByName(ctx context.Context, organizationID *int64, name string) (*GroupModel, error)

func (*Client) GetGroupFolderDefault

func (c *Client) GetGroupFolderDefault(ctx context.Context, groupID int64, folderID int64) (*GroupFolderDefault, error)

func (*Client) GetGroupMember

func (c *Client) GetGroupMember(ctx context.Context, groupID, userID int64) (*GroupMember, error)

func (*Client) GetGroupPage

func (c *Client) GetGroupPage(ctx context.Context, groupID int64, pageID int64) (*GroupPage, error)

func (*Client) GetGroupResource

func (c *Client) GetGroupResource(ctx context.Context, groupID int64, resourceID int64) (*GroupResource, error)

func (*Client) GetGroupResourceFolderDefault

func (c *Client) GetGroupResourceFolderDefault(ctx context.Context, groupID int64, folderID int64) (*GroupResourceFolderDefault, error)

func (*Client) GetPage

func (c *Client) GetPage(ctx context.Context, id int64) (*PageModel, error)

func (*Client) GetResource

func (c *Client) GetResource(ctx context.Context, id int64) (*ResourceModel, error)

func (*Client) GetUserByEmail

func (c *Client) GetUserByEmail(ctx context.Context, email string) (*RESTUser, annotations.Annotations, error)

GetUserByEmail resolves a user by email via the server-side filter. Returns ErrUserNotFound when no user matches and an error if the match is ambiguous.

func (*Client) GetUserSID

func (c *Client) GetUserSID(ctx context.Context, legacyID int64) (string, error)

GetUserSID resolves a Postgres user id (the int64 that baton keys `user:<int64>` on, surfaced as `legacy_id` over REST) to its stable `sid` (`user_<uuid>`), which is the id every REST user endpoint addresses users by. Because the connector always holds the Postgres pool, this is the robust int64->UUID join — no mutable-email lookup required.

func (*Client) InsertGroupPage

func (c *Client) InsertGroupPage(ctx context.Context, groupID int64, pageID int64, accessLevel string) error

func (*Client) ListGroupMembers

func (c *Client) ListGroupMembers(ctx context.Context, groupID int64, pager *Pager, skipDisabledUsers bool) ([]*GroupMember, string, error)

func (*Client) ListGroupsForOrg

func (c *Client) ListGroupsForOrg(ctx context.Context, orgID int64, pager *Pager) ([]*GroupModel, string, error)

func (*Client) ListOrganizations

func (c *Client) ListOrganizations(ctx context.Context, pager *Pager) ([]*OrgModel, string, error)

select id, domain, name, hostname, subdomain from organizations;.

func (*Client) ListPagesForOrg

func (c *Client) ListPagesForOrg(ctx context.Context, orgID int64, pager *Pager) ([]*PageModel, string, error)

func (*Client) ListResourcesForOrg

func (c *Client) ListResourcesForOrg(ctx context.Context, orgID int64, pager *Pager) ([]*ResourceModel, string, error)

func (*Client) ListUsersForOrg

func (c *Client) ListUsersForOrg(ctx context.Context, orgID int64, pager *Pager, skipDisabledUsers bool) ([]*UserModel, string, error)

func (*Client) RESTEnabled

func (c *Client) RESTEnabled() bool

RESTEnabled reports whether the REST surface (account lifecycle) is configured.

func (*Client) RemoveGroupMember

func (c *Client) RemoveGroupMember(ctx context.Context, groupID, userID int64) error

func (*Client) SetUserActive

func (c *Client) SetUserActive(ctx context.Context, sid string, active bool) (annotations.Annotations, error)

SetUserActive enables (active=true) or disables (active=false) a user by sid. Idempotent: patching to the current state succeeds. Retool has no hard delete — this deactivation/reactivation pair is the whole account lifecycle after create.

func (*Client) UpdateGroupMember

func (c *Client) UpdateGroupMember(ctx context.Context, groupID, userID int64, isAdmin bool) (*GroupMember, error)

func (*Client) UpdateGroupPage

func (c *Client) UpdateGroupPage(ctx context.Context, id int64, accessLevel string) error

func (*Client) ValidateConnection

func (c *Client) ValidateConnection(ctx context.Context) error

func (*Client) ValidateREST

func (c *Client) ValidateREST(ctx context.Context) (annotations.Annotations, error)

ValidateREST cheaply confirms the REST token + base URL work (used by Validate()).

type CreateUserParams

type CreateUserParams struct {
	Email     string
	FirstName string
	LastName  string
	UserType  string
}

CreateUserParams are the fields required to provision a new Retool user.

type GroupFolderDefault

type GroupFolderDefault struct {
	ID          int64  `db:"id"`
	AccessLevel string `db:"accessLevel"`
}

type GroupMember

type GroupMember struct {
	Id      int64  `db:"id"`
	UserID  *int64 `db:"userId"`
	GroupID *int64 `db:"groupId"`
	IsAdmin bool   `db:"isAdmin"`
	Enabled bool   `db:"enabled"`
}

func (*GroupMember) GetGroupID

func (g *GroupMember) GetGroupID() int64

func (*GroupMember) GetUserID

func (g *GroupMember) GetUserID() int64

type GroupModel

type GroupModel struct {
	ID                          int64   `db:"id"`
	Name                        *string `db:"name"`
	OrganizationID              *int64  `db:"organizationId"`
	UniversalAccess             string  `db:"universalAccess"`
	UniversalResourceAccess     string  `db:"universalResourceAccess"`
	UniversalQueryLibraryAccess string  `db:"universalQueryLibraryAccess"`
	UserListAccess              bool    `db:"userListAccess"`
	AuditLogAccess              bool    `db:"auditLogAccess"`
	UnpublishedReleaseAccess    bool    `db:"unpublishedReleaseAccess"`
}

func (*GroupModel) GetName

func (g *GroupModel) GetName() string

func (*GroupModel) GetOrgID

func (g *GroupModel) GetOrgID() int64

type GroupPage

type GroupPage struct {
	ID          int64  `db:"id"`
	AccessLevel string `db:"accessLevel"`
}

type GroupResource

type GroupResource struct {
	ID          int64  `db:"id"`
	AccessLevel string `db:"accessLevel"`
}

type GroupResourceFolderDefault

type GroupResourceFolderDefault struct {
	ID          int64  `db:"id"`
	AccessLevel string `db:"accessLevel"`
}

type Logger

type Logger struct{}

func (*Logger) Log

func (log *Logger) Log(ctx context.Context, level tracelog.LogLevel, msg string, data map[string]interface{})

func (*Logger) Pgx2ZapLogLevel

func (log *Logger) Pgx2ZapLogLevel(level tracelog.LogLevel) zapcore.Level

func (*Logger) Zap2PgxLogLevel

func (log *Logger) Zap2PgxLogLevel(level zapcore.Level) tracelog.LogLevel

type OrgModel

type OrgModel struct {
	ID   int64  `db:"id"`
	Name string `db:"name"`
}

type PageModel

type PageModel struct {
	ID             int64   `db:"id"`
	Name           string  `db:"name"`
	OrganizationID *int64  `db:"organizationId"`
	FolderID       int64   `db:"folderId"`
	PhotoUrl       *string `db:"photoUrl"`
	Description    *string `db:"description"`
}

func (*PageModel) GetDescription

func (g *PageModel) GetDescription() string

func (*PageModel) GetOrgID

func (g *PageModel) GetOrgID() int64

func (*PageModel) GetPhotoUrl

func (g *PageModel) GetPhotoUrl() string

type Pager

type Pager struct {
	Token string
	Size  int
}

func (*Pager) Parse

func (p *Pager) Parse() (int, int, error)

Parse returns the offset and page size.

type RESTUser

type RESTUser struct {
	ID        string `json:"id"`
	LegacyID  int64  `json:"legacy_id"`
	Email     string `json:"email"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	Active    bool   `json:"active"`
	UserType  string `json:"user_type"`
}

RESTUser is the Retool REST representation of a user. `ID` is the stable `sid` (user_<uuid>); `LegacyID` is the Postgres `users.id` that baton keys `user:<int64>` on.

type ResourceModel

type ResourceModel struct {
	ID               int64   `db:"id"`
	OrganizationID   int64   `db:"organizationId"`
	Name             string  `db:"name"`
	Type             string  `db:"type"`
	DisplayName      *string `db:"displayName"`
	EnvironmentID    *string `db:"environmentId"`
	ResourceFolderID *int64  `db:"resourceFolderId"`
}

func (*ResourceModel) GetDisplayName

func (u *ResourceModel) GetDisplayName() string

func (*ResourceModel) GetEnvironmentID

func (u *ResourceModel) GetEnvironmentID() string

func (*ResourceModel) GetResourceFolderID

func (g *ResourceModel) GetResourceFolderID() int64

type RetoolErrorResponse

type RetoolErrorResponse struct {
	Success bool   `json:"success"`
	Msg     string `json:"message"`
}

RetoolErrorResponse satisfies uhttp.ErrorResponse so error bodies surface their message.

func (*RetoolErrorResponse) Message

func (e *RetoolErrorResponse) Message() string

type UserModel

type UserModel struct {
	ID              int64      `db:"id"`
	Email           string     `db:"email"`
	FirstName       *string    `db:"firstName"`
	LastName        *string    `db:"lastName"`
	ProfilePhotoURL *string    `db:"profilePhotoUrl"`
	UserName        *string    `db:"userName"`
	Enabled         bool       `db:"enabled"`
	LastLoggedIn    *time.Time `db:"lastLoggedIn"`
	OrganizationID  int64      `db:"organizationId"`
}

func (*UserModel) GetFirstName

func (u *UserModel) GetFirstName() string

func (*UserModel) GetLastLoggedIn

func (u *UserModel) GetLastLoggedIn() time.Time

func (*UserModel) GetLastName

func (u *UserModel) GetLastName() string

func (*UserModel) GetProfilePhotoUrl

func (u *UserModel) GetProfilePhotoUrl() string

func (*UserModel) GetUserName

func (u *UserModel) GetUserName() string

Jump to

Keyboard shortcuts

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