client

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

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 added in v0.0.8

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

func (*Client) CreateGroup added in v0.0.11

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

func (*Client) CreateUser added in v0.0.16

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 added in v0.0.11

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 added in v0.0.11

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 added in v0.0.8

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 added in v0.0.16

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 added in v0.0.16

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 added in v0.0.11

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 added in v0.0.16

func (c *Client) RESTEnabled() bool

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

func (*Client) RemoveGroupMember added in v0.0.8

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

func (*Client) SetUserActive added in v0.0.16

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 added in v0.0.8

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

func (*Client) UpdateGroupPage added in v0.0.11

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 added in v0.0.16

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

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

type CreateUserParams added in v0.0.16

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 added in v0.0.6

type Logger struct{}

func (*Logger) Log added in v0.0.6

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

func (*Logger) Pgx2ZapLogLevel added in v0.0.6

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

func (*Logger) Zap2PgxLogLevel added in v0.0.6

func (log *Logger) Zap2PgxLogLevel(level zapcore.Level) pgx.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 added in v0.0.16

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 added in v0.0.16

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

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

func (*RetoolErrorResponse) Message added in v0.0.16

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