space

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package space provides all the required functions to manage the definition of spaces.

Index

Constants

This section is empty.

Variables

View Source
var (
	SystemSpace = uuid.FromStringOrNil("2e0698d8-753e-4cef-bb7c-f027634824a2")
	SpaceType   = "spaces"
)

Functions

This section is empty.

Types

type GormRepository

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

GormRepository implements SpaceRepository using gorm

func NewRepository

func NewRepository(db *gorm.DB) *GormRepository

NewRepository creates a new space repo

func (*GormRepository) Create

func (r *GormRepository) Create(ctx context.Context, space *Space) (*Space, error)

Create creates a new Space in the db returns BadParameterError or InternalError

func (*GormRepository) Delete

func (r *GormRepository) Delete(ctx context.Context, ID uuid.UUID) error

Delete deletes the space with the given id returns NotFoundError or InternalError

func (*GormRepository) List

func (r *GormRepository) List(ctx context.Context, start *int, limit *int) ([]Space, uint64, error)

List returns work item selected by the given criteria.Expression, starting with start (zero-based) and returning at most limit items

func (*GormRepository) Load

func (r *GormRepository) Load(ctx context.Context, ID uuid.UUID) (*Space, error)

Load returns the space for the given id returns NotFoundError or InternalError

func (*GormRepository) LoadByOwner

func (r *GormRepository) LoadByOwner(ctx context.Context, userID *uuid.UUID, start *int, limit *int) ([]Space, uint64, error)

func (*GormRepository) LoadByOwnerAndName

func (r *GormRepository) LoadByOwnerAndName(ctx context.Context, userID *uuid.UUID, spaceName *string) (*Space, error)

func (*GormRepository) Save

func (r *GormRepository) Save(ctx context.Context, p *Space) (*Space, error)

Save updates the given space in the db. Version must be the same as the one in the stored version returns NotFoundError, BadParameterError, VersionConflictError or InternalError

func (*GormRepository) Search

func (r *GormRepository) Search(ctx context.Context, q *string, start *int, limit *int) ([]Space, uint64, error)

type GormResourceRepository

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

GormResourceRepository implements ResourceRepository using gorm

func NewResourceRepository

func NewResourceRepository(db *gorm.DB) *GormResourceRepository

NewResourceRepository creates a new space resource repo

func (*GormResourceRepository) Create

func (r *GormResourceRepository) Create(ctx context.Context, resource *Resource) (*Resource, error)

Create creates a new Space Resource in the DB returns InternalError

func (*GormResourceRepository) Delete

func (r *GormResourceRepository) Delete(ctx context.Context, ID uuid.UUID) error

Delete deletes the space resource with the given id returns NotFoundError or InternalError

func (*GormResourceRepository) Load

Load returns the space resource for the given id returns NotFoundError or InternalError

func (*GormResourceRepository) LoadBySpace

func (r *GormResourceRepository) LoadBySpace(ctx context.Context, spaceID *uuid.UUID) (*Resource, error)

LoadBySpace loads space resource by space ID

func (*GormResourceRepository) Save

Save updates the given space resource in the DB returns NotFoundError or InternalError

type Repository

type Repository interface {
	Create(ctx context.Context, space *Space) (*Space, error)
	Save(ctx context.Context, space *Space) (*Space, error)
	Load(ctx context.Context, ID uuid.UUID) (*Space, error)
	Delete(ctx context.Context, ID uuid.UUID) error
	LoadByOwner(ctx context.Context, userID *uuid.UUID, start *int, length *int) ([]Space, uint64, error)
	LoadByOwnerAndName(ctx context.Context, userID *uuid.UUID, spaceName *string) (*Space, error)
	List(ctx context.Context, start *int, length *int) ([]Space, uint64, error)
	Search(ctx context.Context, q *string, start *int, length *int) ([]Space, uint64, error)
}

Repository encapsulate storage & retrieval of spaces

type Resource

type Resource struct {
	gormsupport.Lifecycle
	ID           uuid.UUID `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key"`
	ResourceID   string
	PermissionID string
	PolicyID     string
	SpaceID      uuid.UUID `sql:"type:uuid"` // Belongs to Space
}

Resource represents a Keycloak space resource on the domain and db layer

func (Resource) Equal

func (r Resource) Equal(u convert.Equaler) bool

Equal returns true if two Space Resource objects are equal; otherwise false is returned.

func (Resource) TableName

func (r Resource) TableName() string

TableName implements gorm.tabler

type ResourceRepository

type ResourceRepository interface {
	Create(ctx context.Context, space *Resource) (*Resource, error)
	Save(ctx context.Context, space *Resource) (*Resource, error)
	Load(ctx context.Context, ID uuid.UUID) (*Resource, error)
	Delete(ctx context.Context, ID uuid.UUID) error
	LoadBySpace(ctx context.Context, spaceID *uuid.UUID) (*Resource, error)
}

ResourceRepository encapsulate storage & retrieval of space resources

type Space

type Space struct {
	gormsupport.Lifecycle
	ID          uuid.UUID
	Version     int
	Name        string
	Description string
	OwnerId     uuid.UUID `sql:"type:uuid"` // Belongs To Identity
}

Space represents a Space on the domain and db layer

func (Space) Equal

func (p Space) Equal(u convert.Equaler) bool

Equal returns true if two Space objects are equal; otherwise false is returned.

func (Space) GetETagData

func (p Space) GetETagData() []interface{}

GetETagData returns the field values to use to generate the ETag

func (Space) GetLastModified

func (p Space) GetLastModified() time.Time

GetLastModified returns the last modification time

Directories

Path Synopsis
Package authz contains the code that authorizes space operations
Package authz contains the code that authorizes space operations

Jump to

Keyboard shortcuts

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