resources

package
v5.0.0-...-b98a0e9 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package resources provides ready-to-use SQL schemes and DAOs for attaching resource policies to any data

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

Types

type DAO

type DAO interface {
	Migrate(ctx context.Context) error

	AddPolicy(ctx context.Context, resourceId string, policy *service.ResourcePolicy) error
	AddPolicies(ctx context.Context, update bool, resourceId string, rules []*service.ResourcePolicy) error
	GetPoliciesForResource(ctx context.Context, resourceId string) ([]*service.ResourcePolicy, error)
	GetPoliciesForSubject(ctx context.Context, subject string) ([]*service.ResourcePolicy, error)
	ReplacePoliciesSubject(ctx context.Context, oldSubject, newSubject string) (int, error)
	DeletePoliciesForResource(ctx context.Context, resourceId string) error
	DeletePoliciesForResourceAndAction(ctx context.Context, resourceId string, action service.ResourcePolicyAction) error
	DeletePoliciesBySubject(ctx context.Context, subject string) error

	service.Converter[*gorm.DB]
}

DAO interface

func NewDAO

func NewDAO(db *gorm.DB) DAO

type QueryBuilder

type QueryBuilder struct {
	DAO
	LeftIdentifier string
}

func PrepareQueryBuilder

func PrepareQueryBuilder(refModel any, refDAO DAO, naming schema.Namer) (*QueryBuilder, error)

PrepareQueryBuilder instantiates a QueryBuilder with a proper LeftIdentifier

func (*QueryBuilder) Convert

func (r *QueryBuilder) Convert(ctx context.Context, val *anypb.Any, db *gorm.DB) (*gorm.DB, bool, error)

Jump to

Keyboard shortcuts

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