organization

package
v0.7.10 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

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

	AdminPermission = schema.UpdatePermission
	AdminRole       = schema.OwnerRelationName
)

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
	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
}

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,
	disableOrgsOnCreate bool) *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) 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) ([]Organization, 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