user

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package user contains the functionality and types needed to interact with the User API.

See https://www.metabase.com/docs/latest/api/user.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateRequest

type CreateRequest struct {
	Email            string             `json:"email"`
	FirstName        *string            `json:"first_name"`
	LastName         *string            `json:"last_name"`
	GroupMemberships *[]GroupMembership `json:"user_group_memberships"`
	LoginAttributes  *LoginAttributes   `json:"login_attributes"`
}

CreateRequest represents the request body used to create a new user.

type GroupMembership

type GroupMembership struct {
	Id             int64 `json:"id"`
	IsGroupManager bool  `json:"is_group_manager"`
}

type LoginAttributes

type LoginAttributes map[string]string

type SSOSource

type SSOSource string
const (
	SSOSourceSAML SSOSource = "saml"
)

type Service

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

func New

func New(httpClient *http.Client) *Service

New returns an initialised user Service for use by the client. This should only be used internally by the SDK.

func (*Service) Create

func (u *Service) Create(ctx context.Context, request *CreateRequest) (int64, error)

Create creates a new user and returns the user's ID. This will automatically remove the permissions.GroupAllUsers and permissions.GroupAdministrators groups if specified, as users cannot be opted into these via the GroupMemberships field.

func (*Service) Disable

func (u *Service) Disable(ctx context.Context, id int64) error

Disable is used to deactivate users, as users cannot be deleted in Metabase. Deactivated users are unable to log into or access Metabase.

func (*Service) Get

func (u *Service) Get(ctx context.Context, id int64) (*User, error)

Get fetches the details of an existing user.

func (*Service) GetCurrentUser

func (u *Service) GetCurrentUser(ctx context.Context) (*User, error)

GetCurrentUser fetches the details of the currently authenticated user. For API keys, the FirstName field is set to the name of the API key and the Email field is set to an invalid email address.

func (*Service) Reactivate

func (u *Service) Reactivate(ctx context.Context, id int64) error

Reactivate is used to enable a user that has previously been disabled so that they can access Metabase again.

func (*Service) Update

func (u *Service) Update(ctx context.Context, id int64, request *UpdateRequest) error

Update updates the details of an existing user. This will automatically remove the permissions.GroupAllUsers and permissions.GroupAdministrators groups if specified, as users cannot be opted into these via the GroupMemberships field. The Id field is also set automatically, so consumers do not need to set this explicitly.

type UpdateRequest

type UpdateRequest struct {
	Id               int64              `json:"id"`
	Email            *string            `json:"email"`
	FirstName        *string            `json:"first_name"`
	LastName         *string            `json:"last_name"`
	Locale           *string            `json:"locale"`
	IsGroupManager   *bool              `json:"is_group_manager"`
	IsSuperuser      *bool              `json:"is_superuser"`
	LoginAttributes  *LoginAttributes   `json:"login_attributes"`
	GroupMemberships *[]GroupMembership `json:"user_group_memberships"`
}

UpdateRequest represents the request body to update an existing user.

type User

type User struct {
	Id         int64   `json:"id"`
	FirstName  *string `json:"first_name"`
	LastName   *string `json:"last_name"`
	CommonName *string `json:"common_name"`
	Email      string  `json:"email"`
	Locale     *string `json:"locale"`

	IsActive    bool  `json:"is_active"`
	IsQbnewb    bool  `json:"is_qbnewb"`
	IsSuperuser bool  `json:"is_superuser"`
	IsInstaller *bool `json:"is_installer"`

	LoginAttributes  *LoginAttributes  `json:"login_attributes"`
	GroupMemberships []GroupMembership `json:"user_group_memberships"`

	GoogleAuth bool       `json:"google_auth"`
	SSOSource  *SSOSource `json:"sso_source"`

	HasInvitedSecondUser    bool        `json:"has_invited_second_user"`
	HasQuestionAndDashboard bool        `json:"has_question_and_dashboard"`
	PersonalCollectionId    interface{} `json:"personal_collection_id"`

	DateJoined string  `json:"date_joined"`
	FirstLogin *string `json:"first_login"`
	LastLogin  *string `json:"last_login"`
	UpdatedAt  *string `json:"updated_at"`
}

User represents the details of an existing user returned from the Metabase API.

Jump to

Keyboard shortcuts

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