project

package
v0.105.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotExist             = errors.New("project or its relations doesn't exist")
	ErrInvalidUUID          = errors.New("invalid syntax of uuid")
	ErrInvalidID            = errors.New("project id is invalid")
	ErrConflict             = errors.New("project already exist")
	ErrInvalidDetail        = errors.New("invalid project detail")
	ErrInvalidProjectRole   = errors.New("role is not valid for project scope")
	ErrNotOrgMember         = errors.New("user is not a member of the organization")
	ErrInvalidPrincipalType = errors.New("invalid principal type")
	ErrNotMember            = errors.New("principal is not a member of the project")
)
View Source
var AdminPermission = schema.DeletePermission
View Source
var MemberPermission = schema.GetPermission

Functions

This section is empty.

Types

type AuthnService added in v0.7.4

type AuthnService interface {
	GetPrincipal(ctx context.Context, via ...authenticate.ClientAssertion) (authenticate.Principal, error)
}

type Filter

type Filter struct {
	OrgID           string
	WithMemberCount bool
	ProjectIDs      []string
	State           State
	// NonInherited filters out projects that are inherited from access given through an organization
	NonInherited bool
	Pagination   *pagination.Pagination

	// OrgIDs narrows results to projects whose org_id is in this list. Used by
	// membership listing to batch-expand all projects across the orgs a
	// principal can inherit project visibility from. If both OrgID and OrgIDs
	// are set, projects must satisfy both (intersection) — typically yields
	// no rows unless OrgID is one of OrgIDs.
	OrgIDs []string

	// Principal narrows results to projects on which the principal has a
	// policy (direct, via group membership, or org-inheritance unless
	// NonInherited is set). When combined with ProjectIDs the two are
	// intersected. Resolved by membership.Service.
	Principal *authenticate.Principal
}

type GroupService added in v0.7.6

type GroupService interface {
	Get(ctx context.Context, id string) (group.Group, error)
}

type MembershipService added in v0.104.0

type MembershipService interface {
	ListProjectsByPrincipal(ctx context.Context, principal authenticate.Principal, orgID string, nonInherited bool) ([]string, error)
}

type PolicyService added in v0.7.4

type PolicyService interface {
	Create(ctx context.Context, policy policy.Policy) (policy.Policy, error)
	List(ctx context.Context, flt policy.Filter) ([]policy.Policy, error)
	Delete(ctx context.Context, id string) error
	ProjectMemberCount(ctx context.Context, ids []string) ([]policy.MemberCount, error)
}

type Project

type Project struct {
	ID           string
	Name         string
	Title        string
	Organization organization.Organization
	State        State
	Metadata     metadata.Metadata

	CreatedAt time.Time
	UpdatedAt time.Time

	// Transient fields
	MemberCount int
}

type RelationService

type RelationService interface {
	Create(ctx context.Context, rel relation.Relation) (relation.Relation, error)
	LookupSubjects(ctx context.Context, rel relation.Relation) ([]string, error)
	Delete(ctx context.Context, rel relation.Relation) error
}

type Repository

type Repository interface {
	GetByID(ctx context.Context, id string) (Project, error)
	GetByName(ctx context.Context, slug string) (Project, error)
	Create(ctx context.Context, org Project) (Project, error)
	List(ctx context.Context, f Filter) ([]Project, error)
	UpdateByID(ctx context.Context, toUpdate Project) (Project, error)
	UpdateByName(ctx context.Context, toUpdate Project) (Project, error)
	Delete(ctx context.Context, id string) error
	SetState(ctx context.Context, id string, state State) error
}

type RoleService added in v0.96.0

type RoleService interface {
	Get(ctx context.Context, id string) (role.Role, error)
}

type Service

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

func NewService

func NewService(repository Repository, relationService RelationService, userService UserService,
	policyService PolicyService, authnService AuthnService, suserService ServiceuserService,
	groupService GroupService, roleService RoleService) *Service

func (Service) Create

func (s Service) Create(ctx context.Context, prj Project) (Project, error)

func (Service) DeleteModel

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

DeleteModel doesn't delete the nested resource, only itself

func (Service) Disable

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

func (Service) Enable

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

func (Service) Get

func (s Service) Get(ctx context.Context, idOrName string) (Project, error)

func (Service) List

func (s Service) List(ctx context.Context, f Filter) ([]Project, error)

func (Service) RemoveMember added in v0.96.0

func (s Service) RemoveMember(ctx context.Context, projectID, principalID, principalType string) error

RemoveMember removes a principal from a project by deleting all their project-level policies. Supported principal types: user, service user, group.

func (Service) SetMemberRole added in v0.96.0

func (s Service) SetMemberRole(ctx context.Context, projectID, principalID, principalType, newRoleID string) error

SetMemberRole sets a principal's role in a project. It deletes any existing project-level policies for the principal and creates a new one. Supported principal types: user, service user, group.

func (*Service) SetMembershipService added in v0.104.0

func (s *Service) SetMembershipService(ms MembershipService)

SetMembershipService sets the membership dependency after construction to break the circular init order between project and membership services.

func (Service) Update

func (s Service) Update(ctx context.Context, prj Project) (Project, error)

type ServiceuserService added in v0.7.5

type ServiceuserService interface {
	Get(ctx context.Context, id string) (serviceuser.ServiceUser, error)
	GetByIDs(ctx context.Context, ids []string) ([]serviceuser.ServiceUser, error)
	FilterSudos(ctx context.Context, ids []string) ([]string, error)
}

type State

type State string
const (
	Enabled  State = "enabled"
	Disabled State = "disabled"
)

func (State) String

func (s State) String() string

type UserService

type UserService interface {
	GetByID(ctx context.Context, id string) (user.User, error)
	GetByIDs(ctx context.Context, userIDs []string) ([]user.User, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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