team

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoleOwner  = "owner"
	RoleMember = "member"

	SourceManual = "manual"
	SourceSSO    = "sso"

	OwnerTypeUser = "user"
	OwnerTypeTeam = "team"
)

Variables

View Source
var (
	ErrTeamNotFound         = errors.New("team not found")
	ErrTeamNameExists       = errors.New("team name already exists")
	ErrMemberNotFound       = errors.New("member not found")
	ErrMemberAlreadyExists  = errors.New("member already exists")
	ErrMappingNotFound      = errors.New("sso mapping not found")
	ErrMappingAlreadyExists = errors.New("sso mapping already exists")
	ErrCannotEditSSOTeam    = errors.New("cannot edit SSO-managed team")
)

Functions

This section is empty.

Types

type AssetOwner

type AssetOwner struct {
	AssetID   string    `json:"asset_id"`
	UserID    *string   `json:"user_id,omitempty"`
	TeamID    *string   `json:"team_id,omitempty"`
	CreatedAt time.Time `json:"created_at"`
}

type Owner

type Owner struct {
	Type           string  `json:"type"`
	ID             string  `json:"id"`
	Name           string  `json:"name"`
	Username       *string `json:"username,omitempty"`
	Email          *string `json:"email,omitempty"`
	ProfilePicture *string `json:"profile_picture,omitempty"`
}

type PostgresRepository

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

func (*PostgresRepository) AddAssetOwner

func (r *PostgresRepository) AddAssetOwner(ctx context.Context, assetID, ownerType, ownerID string) error

func (*PostgresRepository) AddMember

func (r *PostgresRepository) AddMember(ctx context.Context, member *TeamMember) error

func (*PostgresRepository) ConvertMemberToManual

func (r *PostgresRepository) ConvertMemberToManual(ctx context.Context, teamID, userID string) error

func (*PostgresRepository) CreateSSOMapping

func (r *PostgresRepository) CreateSSOMapping(ctx context.Context, mapping *SSOTeamMapping) error

func (*PostgresRepository) CreateTeam

func (r *PostgresRepository) CreateTeam(ctx context.Context, team *Team) error

func (*PostgresRepository) DeleteSSOMapping

func (r *PostgresRepository) DeleteSSOMapping(ctx context.Context, id string) error

func (*PostgresRepository) DeleteTeam

func (r *PostgresRepository) DeleteTeam(ctx context.Context, id string) error

func (*PostgresRepository) FindSimilarTeamNames added in v0.5.0

func (r *PostgresRepository) FindSimilarTeamNames(ctx context.Context, searchTerm string, limit int) ([]string, error)

FindSimilarTeamNames finds team names similar to the given search term

func (*PostgresRepository) GetMappingsForGroups

func (r *PostgresRepository) GetMappingsForGroups(ctx context.Context, provider string, groups []string) ([]*SSOTeamMapping, error)

func (*PostgresRepository) GetMember

func (r *PostgresRepository) GetMember(ctx context.Context, teamID, userID string) (*TeamMember, error)

func (*PostgresRepository) GetSSOMapping

func (r *PostgresRepository) GetSSOMapping(ctx context.Context, id string) (*SSOTeamMapping, error)

func (*PostgresRepository) GetTeam

func (r *PostgresRepository) GetTeam(ctx context.Context, id string) (*Team, error)

func (*PostgresRepository) GetTeamByName

func (r *PostgresRepository) GetTeamByName(ctx context.Context, name string) (*Team, error)

func (*PostgresRepository) IsUserInTeam

func (r *PostgresRepository) IsUserInTeam(ctx context.Context, userID, teamID string) (bool, error)

func (*PostgresRepository) ListAssetOwners

func (r *PostgresRepository) ListAssetOwners(ctx context.Context, assetID string) ([]*Owner, error)

func (*PostgresRepository) ListAssetsByOwner

func (r *PostgresRepository) ListAssetsByOwner(ctx context.Context, ownerType, ownerID string) ([]string, error)

func (*PostgresRepository) ListMembers

func (r *PostgresRepository) ListMembers(ctx context.Context, teamID string) ([]*TeamMemberWithUser, error)

func (*PostgresRepository) ListSSOMappings

func (r *PostgresRepository) ListSSOMappings(ctx context.Context, provider string) ([]*SSOTeamMapping, error)

func (*PostgresRepository) ListTeams

func (r *PostgresRepository) ListTeams(ctx context.Context, limit, offset int) ([]*Team, int, error)

func (*PostgresRepository) ListUserTeams

func (r *PostgresRepository) ListUserTeams(ctx context.Context, userID string) ([]*Team, error)

func (*PostgresRepository) RemoveAssetOwner

func (r *PostgresRepository) RemoveAssetOwner(ctx context.Context, assetID, ownerType, ownerID string) error

func (*PostgresRepository) RemoveMember

func (r *PostgresRepository) RemoveMember(ctx context.Context, teamID, userID string) error

func (*PostgresRepository) SearchOwners

func (r *PostgresRepository) SearchOwners(ctx context.Context, query string, limit int) ([]*Owner, error)

func (*PostgresRepository) TeamExists

func (r *PostgresRepository) TeamExists(ctx context.Context, id string) (bool, error)

func (*PostgresRepository) UpdateMemberRole

func (r *PostgresRepository) UpdateMemberRole(ctx context.Context, teamID, userID, role string) error

func (*PostgresRepository) UpdateSSOMapping

func (r *PostgresRepository) UpdateSSOMapping(ctx context.Context, id, teamID, memberRole string) error

func (*PostgresRepository) UpdateTeam

func (r *PostgresRepository) UpdateTeam(ctx context.Context, id, name, description string) error

func (*PostgresRepository) UpdateTeamFields added in v0.5.0

func (r *PostgresRepository) UpdateTeamFields(ctx context.Context, id string, name, description *string, metadata map[string]interface{}, tags []string) error

type Repository

type Repository interface {
	CreateTeam(ctx context.Context, team *Team) error
	GetTeam(ctx context.Context, id string) (*Team, error)
	GetTeamByName(ctx context.Context, name string) (*Team, error)
	FindSimilarTeamNames(ctx context.Context, searchTerm string, limit int) ([]string, error)
	UpdateTeam(ctx context.Context, id string, name, description string) error
	UpdateTeamFields(ctx context.Context, id string, name, description *string, metadata map[string]interface{}, tags []string) error
	DeleteTeam(ctx context.Context, id string) error
	ListTeams(ctx context.Context, limit, offset int) ([]*Team, int, error)
	TeamExists(ctx context.Context, id string) (bool, error)

	AddMember(ctx context.Context, member *TeamMember) error
	RemoveMember(ctx context.Context, teamID, userID string) error
	UpdateMemberRole(ctx context.Context, teamID, userID, role string) error
	GetMember(ctx context.Context, teamID, userID string) (*TeamMember, error)
	ListMembers(ctx context.Context, teamID string) ([]*TeamMemberWithUser, error)
	ListUserTeams(ctx context.Context, userID string) ([]*Team, error)
	IsUserInTeam(ctx context.Context, userID, teamID string) (bool, error)
	ConvertMemberToManual(ctx context.Context, teamID, userID string) error

	CreateSSOMapping(ctx context.Context, mapping *SSOTeamMapping) error
	GetSSOMapping(ctx context.Context, id string) (*SSOTeamMapping, error)
	UpdateSSOMapping(ctx context.Context, id, teamID, memberRole string) error
	DeleteSSOMapping(ctx context.Context, id string) error
	ListSSOMappings(ctx context.Context, provider string) ([]*SSOTeamMapping, error)
	GetMappingsForGroups(ctx context.Context, provider string, groups []string) ([]*SSOTeamMapping, error)

	AddAssetOwner(ctx context.Context, assetID, ownerType, ownerID string) error
	RemoveAssetOwner(ctx context.Context, assetID, ownerType, ownerID string) error
	ListAssetOwners(ctx context.Context, assetID string) ([]*Owner, error)
	ListAssetsByOwner(ctx context.Context, ownerType, ownerID string) ([]string, error)

	SearchOwners(ctx context.Context, query string, limit int) ([]*Owner, error)
}

func NewPostgresRepository

func NewPostgresRepository(db *pgxpool.Pool) Repository

type SSOTeamMapping

type SSOTeamMapping struct {
	ID           string    `json:"id"`
	Provider     string    `json:"provider"`
	SSOGroupName string    `json:"sso_group_name"`
	TeamID       string    `json:"team_id"`
	MemberRole   string    `json:"member_role"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

type Service

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

func NewService

func NewService(repo Repository) *Service

func (*Service) AddAssetOwner

func (s *Service) AddAssetOwner(ctx context.Context, assetID, ownerType, ownerID string) error

func (*Service) AddMember

func (s *Service) AddMember(ctx context.Context, teamID, userID, role string) error

func (*Service) CanUserAccessAsset

func (s *Service) CanUserAccessAsset(ctx context.Context, userID, assetID string) (bool, error)

func (*Service) ConvertMemberToManual

func (s *Service) ConvertMemberToManual(ctx context.Context, teamID, userID string) error

func (*Service) CreateSSOMapping

func (s *Service) CreateSSOMapping(ctx context.Context, provider, ssoGroupName, teamID, memberRole string) (*SSOTeamMapping, error)

func (*Service) CreateTeam

func (s *Service) CreateTeam(ctx context.Context, name, description, createdBy string) (*Team, error)

func (*Service) CreateTeamViaSSO

func (s *Service) CreateTeamViaSSO(ctx context.Context, provider, groupName string) (*Team, error)

func (*Service) DeleteSSOMapping

func (s *Service) DeleteSSOMapping(ctx context.Context, id string) error

func (*Service) DeleteTeam

func (s *Service) DeleteTeam(ctx context.Context, id string) error

func (*Service) FindSimilarTeamNames added in v0.5.0

func (s *Service) FindSimilarTeamNames(ctx context.Context, searchTerm string, limit int) ([]string, error)

func (*Service) GetSSOMapping

func (s *Service) GetSSOMapping(ctx context.Context, id string) (*SSOTeamMapping, error)

func (*Service) GetTeam

func (s *Service) GetTeam(ctx context.Context, id string) (*Team, error)

func (*Service) GetTeamByName added in v0.5.0

func (s *Service) GetTeamByName(ctx context.Context, name string) (*Team, error)

func (*Service) ListAssetOwners

func (s *Service) ListAssetOwners(ctx context.Context, assetID string) ([]*Owner, error)

func (*Service) ListAssetsByOwner

func (s *Service) ListAssetsByOwner(ctx context.Context, ownerType, ownerID string) ([]string, error)

func (*Service) ListMembers

func (s *Service) ListMembers(ctx context.Context, teamID string) ([]*TeamMemberWithUser, error)

func (*Service) ListSSOMappings

func (s *Service) ListSSOMappings(ctx context.Context, provider string) ([]*SSOTeamMapping, error)

func (*Service) ListTeams

func (s *Service) ListTeams(ctx context.Context, limit, offset int) ([]*Team, int, error)

func (*Service) ListUserTeams

func (s *Service) ListUserTeams(ctx context.Context, userID string) ([]*Team, error)

func (*Service) RemoveAssetOwner

func (s *Service) RemoveAssetOwner(ctx context.Context, assetID, ownerType, ownerID string) error

func (*Service) RemoveMember

func (s *Service) RemoveMember(ctx context.Context, teamID, userID string) error

func (*Service) SearchOwners

func (s *Service) SearchOwners(ctx context.Context, query string, limit int) ([]*Owner, error)

func (*Service) SyncUserTeamsFromSSO

func (s *Service) SyncUserTeamsFromSSO(ctx context.Context, userID, provider string, ssoGroups []string, syncConfig config.TeamSyncConfig) error

func (*Service) UpdateMemberRole

func (s *Service) UpdateMemberRole(ctx context.Context, teamID, userID, role string) error

func (*Service) UpdateSSOMapping

func (s *Service) UpdateSSOMapping(ctx context.Context, id, teamID, memberRole string) error

func (*Service) UpdateTeam

func (s *Service) UpdateTeam(ctx context.Context, id, name, description string) error

func (*Service) UpdateTeamFields added in v0.5.0

func (s *Service) UpdateTeamFields(ctx context.Context, id string, name, description *string, metadata map[string]interface{}, tags []string) error

type Team

type Team struct {
	ID            string                 `json:"id"`
	Name          string                 `json:"name"`
	Description   string                 `json:"description"`
	Metadata      map[string]interface{} `json:"metadata,omitempty"`
	Tags          []string               `json:"tags,omitempty"`
	CreatedViaSSO bool                   `json:"created_via_sso"`
	SSOProvider   *string                `json:"sso_provider,omitempty"`
	CreatedBy     *string                `json:"created_by,omitempty"`
	CreatedAt     time.Time              `json:"created_at"`
	UpdatedAt     time.Time              `json:"updated_at"`
}

type TeamMember

type TeamMember struct {
	ID          string    `json:"id"`
	TeamID      string    `json:"team_id"`
	UserID      string    `json:"user_id"`
	Role        string    `json:"role"`
	Source      string    `json:"source"`
	SSOProvider *string   `json:"sso_provider,omitempty"`
	JoinedAt    time.Time `json:"joined_at"`
}

type TeamMemberWithUser

type TeamMemberWithUser struct {
	TeamMember
	Username       string  `json:"username"`
	Name           string  `json:"name"`
	Email          *string `json:"email,omitempty"`
	ProfilePicture *string `json:"profile_picture,omitempty"`
}

Jump to

Keyboard shortcuts

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