organization

package
v0.8.30 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Enabled  State = "enabled"
	Disabled State = "disabled"

	AdminPermission = schema.UpdatePermission
	AdminRelation   = schema.OwnerRelationName
	AdminRole       = schema.RoleOrganizationOwner
	MemberRole      = schema.RoleOrganizationViewer
)

Variables

View Source
var (
	ErrNotExist      = errors.New("org doesn't exist")
	ErrInvalidUUID   = errors.New("invalid syntax of uuid")
	ErrInvalidID     = errors.New("org id is invalid")
	ErrConflict      = errors.New("org already exist")
	ErrInvalidDetail = errors.New("invalid org detail")
	ErrDisabled      = errors.New("org is disabled")
)

Functions

This section is empty.

Types

type AuthnService

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

type Filter

type Filter struct {
	UserID string

	IDs   []string
	State State
}

type Organization

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

	CreatedAt time.Time
	UpdatedAt time.Time

	// BillingID is the identifier of the organization in the billing engine
	BillingID string
}

type PolicyService added in v0.7.12

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
	OrgMemberCount(ctx context.Context, id string) (policy.MemberCount, error)
}

type PreferencesService added in v0.7.13

type PreferencesService interface {
	LoadPlatformPreferences(ctx context.Context) (map[string]string, error)
}

type RelationService

type RelationService interface {
	Create(ctx context.Context, rel relation.Relation) (relation.Relation, error)
	LookupResources(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) (Organization, error)
	GetByIDs(ctx context.Context, ids []string) ([]Organization, error)
	GetByName(ctx context.Context, name string) (Organization, error)
	Create(ctx context.Context, org Organization) (Organization, error)
	List(ctx context.Context, flt Filter) ([]Organization, error)
	UpdateByID(ctx context.Context, org Organization) (Organization, error)
	UpdateByName(ctx context.Context, org Organization) (Organization, error)
	SetState(ctx context.Context, id string, state State) error
	Delete(ctx context.Context, id string) error
}

type Service

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

func NewService

func NewService(repository Repository, relationService RelationService,
	userService UserService, authnService AuthnService, policyService PolicyService,
	prefService PreferencesService) *Service

func (Service) AddMember

func (s Service) AddMember(ctx context.Context, orgID, relationName string, principal authenticate.Principal) error

func (Service) AddUsers

func (s Service) AddUsers(ctx context.Context, orgID string, userIDs []string) error

func (Service) AttachToPlatform

func (s Service) AttachToPlatform(ctx context.Context, orgID string) error

func (Service) Create

func (s Service) Create(ctx context.Context, org Organization) (Organization, 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) (Organization, error)

Get returns an enabled organization by id or name. Will return `org is disabled` error if the organization is disabled

func (Service) GetDefaultOrgStateOnCreate added in v0.7.13

func (s Service) GetDefaultOrgStateOnCreate(ctx context.Context) (State, error)

GetDefaultOrgStateOnCreate gets from preferences if we need to disable org on create

func (Service) GetRaw added in v0.7.5

func (s Service) GetRaw(ctx context.Context, idOrName string) (Organization, error)

GetRaw returns an organization(both enabled and disabled) by id or name

func (Service) List

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

func (Service) ListByUser

func (s Service) ListByUser(ctx context.Context, userID string, filter Filter) ([]Organization, error)

func (Service) MemberCount added in v0.8.13

func (s Service) MemberCount(ctx context.Context, orgID string) (int64, error)

func (Service) RemoveUsers

func (s Service) RemoveUsers(ctx context.Context, orgID string, userIDs []string) error

RemoveUsers removes users from an organization as members it doesn't remove user access to projects or other resources provided by policies, don't call directly, use cascade deleter

func (Service) Update

func (s Service) Update(ctx context.Context, org Organization) (Organization, error)

type State

type State string

func (State) String

func (s State) String() string

type UserService

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

Jump to

Keyboard shortcuts

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