resource

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

This section is empty.

Variables

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

Functions

This section is empty.

Types

type AuthnService

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

type Check added in v0.7.4

type Check struct {
	Object     relation.Object
	Subject    relation.Subject
	Permission string
}

type ConfigRepository

type ConfigRepository interface {
	GetAll(ctx context.Context) ([]YAML, error)
}

type Filter

type Filter struct {
	ProjectID     string
	UserID        string
	ServiceUserID string
	NamespaceID   string
}

type OrgService

type OrgService interface {
	Get(ctx context.Context, idOrName string) (organization.Organization, error)
}

type ProjectService

type ProjectService interface {
	Get(ctx context.Context, idOrName string) (project.Project, error)
}

type RelationService

type RelationService interface {
	Create(ctx context.Context, rel relation.Relation) (relation.Relation, error)
	CheckPermission(ctx context.Context, rel relation.Relation) (bool, error)
	BatchCheckPermission(ctx context.Context, relations []relation.Relation) ([]relation.CheckPair, error)
	Delete(ctx context.Context, rel relation.Relation) error
}

type Repository

type Repository interface {
	GetByID(ctx context.Context, id string) (Resource, error)
	GetByURN(ctx context.Context, urn string) (Resource, error)
	Create(ctx context.Context, resource Resource) (Resource, error)
	List(ctx context.Context, flt Filter) ([]Resource, error)
	Update(ctx context.Context, resource Resource) (Resource, error)
	Delete(ctx context.Context, id string) error
}

type Resource

type Resource struct {
	ID            string `json:"id"`
	URN           string `json:"urn"`
	Name          string `json:"name"`
	Title         string `json:"title"`
	ProjectID     string `json:"project_id"`
	NamespaceID   string `json:"namespace_id"`
	PrincipalID   string `json:"principal_id"`
	PrincipalType string `json:"principal_type"`
	Metadata      metadata.Metadata

	CreatedAt time.Time
	UpdatedAt time.Time
}

func (Resource) CreateURN

func (res Resource) CreateURN(projectName string) string

type Service

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

func NewService

func NewService(repository Repository, configRepository ConfigRepository,
	relationService RelationService, authnService AuthnService,
	projectService ProjectService, orgService OrgService) *Service

func (Service) AddProjectToResource

func (s Service) AddProjectToResource(ctx context.Context, projectID string, res Resource) error

func (Service) AddResourceOwner

func (s Service) AddResourceOwner(ctx context.Context, res Resource) error

func (Service) BatchCheck added in v0.7.4

func (s Service) BatchCheck(ctx context.Context, checks []Check) ([]relation.CheckPair, error)

func (Service) CheckAuthz

func (s Service) CheckAuthz(ctx context.Context, check Check) (bool, error)

func (Service) Create

func (s Service) Create(ctx context.Context, res Resource) (Resource, error)

func (Service) Delete

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

func (Service) Get

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

func (Service) List

func (s Service) List(ctx context.Context, flt Filter) ([]Resource, error)

func (Service) Update

func (s Service) Update(ctx context.Context, resource Resource) (Resource, error)

type YAML

type YAML struct {
	Name         string              `json:"name" yaml:"name"`
	Backend      string              `json:"backend" yaml:"backend"`
	ResourceType string              `json:"resource_type" yaml:"resource_type"`
	Actions      map[string][]string `json:"actions" yaml:"actions"`
}

Jump to

Keyboard shortcuts

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