repository

package
v0.0.0-...-2d73068 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: Apache-2.0 Imports: 10 Imported by: 7

Documentation

Overview

Package repository provides the APIs for making resource_type related database interactions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterByResourceTypeID

func FilterByResourceTypeID(id uuid.UUID) func(db *gorm.DB) *gorm.DB

FilterByResourceTypeID is a gorm filter by 'name'

func FilterByScopeName

func FilterByScopeName(name string) func(db *gorm.DB) *gorm.DB

FilterByScopeName is a gorm filter by 'name'

Types

type GormResourceTypeRepository

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

GormResourceTypeRepository is the implementation of the storage interface for ResourceType.

func (*GormResourceTypeRepository) Create

Create creates a new record.

func (*GormResourceTypeRepository) Delete

func (m *GormResourceTypeRepository) Delete(ctx context.Context, id uuid.UUID) error

Delete removes a single record.

func (*GormResourceTypeRepository) List

List return all resource types

func (*GormResourceTypeRepository) Load

func (m *GormResourceTypeRepository) Load(ctx context.Context, id uuid.UUID) (*ResourceType, error)

Load returns a single ResourceType as a Database Model

func (*GormResourceTypeRepository) Lookup

Lookup looks up the ResourceType record with the specified name. If there is no such record, then a gorm.ErrRecordNotFound error will be returned.

func (*GormResourceTypeRepository) Save

Save modifies a single record

func (*GormResourceTypeRepository) TableName

func (m *GormResourceTypeRepository) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

type GormResourceTypeScopeRepository

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

GormResourceTypeScopeRepository is the implementation of the storage interface for ResourceTypeScope.

func (*GormResourceTypeScopeRepository) CheckExists

func (m *GormResourceTypeScopeRepository) CheckExists(ctx context.Context, id string) (bool, error)

CheckExists returns nil if the given ID exists otherwise returns an error

func (*GormResourceTypeScopeRepository) Create

Create creates a new record.

func (*GormResourceTypeScopeRepository) Delete

func (m *GormResourceTypeScopeRepository) Delete(ctx context.Context, id uuid.UUID) error

Delete removes a single record.

func (*GormResourceTypeScopeRepository) List

List return all resource type scopes

func (*GormResourceTypeScopeRepository) Load

Load returns a single ResourceTypeScope as a Database Model This is more for use internally, and probably not what you want in your controllers

func (*GormResourceTypeScopeRepository) LookupByResourceTypeAndScope

func (m *GormResourceTypeScopeRepository) LookupByResourceTypeAndScope(ctx context.Context, resourceTypeID uuid.UUID, name string) (*ResourceTypeScope, error)

LookupByResourceTypeAndScope returns all resource type scopes filtered by name and scope.

func (*GormResourceTypeScopeRepository) LookupForType

func (m *GormResourceTypeScopeRepository) LookupForType(ctx context.Context, resourceTypeID uuid.UUID) ([]ResourceTypeScope, error)

func (*GormResourceTypeScopeRepository) Query

func (m *GormResourceTypeScopeRepository) Query(funcs ...func(*gorm.DB) *gorm.DB) ([]ResourceTypeScope, error)

Query expose an open ended Query model

func (*GormResourceTypeScopeRepository) Save

Save modifies a single record

func (*GormResourceTypeScopeRepository) TableName

func (m *GormResourceTypeScopeRepository) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

type ResourceType

type ResourceType struct {
	gormsupport.Lifecycle

	ResourceTypeID uuid.UUID `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key;column:resource_type_id"`
	// The resource type name
	Name string

	DefaultRoleID *uuid.UUID `sql:"type:string" gorm:"column:default_role_id"`
}

func (ResourceType) GetLastModified

func (m ResourceType) GetLastModified() time.Time

GetLastModified returns the last modification time

func (ResourceType) TableName

func (m ResourceType) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

type ResourceTypeRepository

type ResourceTypeRepository interface {
	Create(ctx context.Context, u *ResourceType) error
	Lookup(ctx context.Context, name string) (*ResourceType, error)
	List(ctx context.Context) ([]ResourceType, error)
	Save(ctx context.Context, u *ResourceType) error
	Delete(ctx context.Context, ID uuid.UUID) error
	Load(ctx context.Context, ID uuid.UUID) (*ResourceType, error)
}

ResourceTypeRepository represents the storage interface.

func NewResourceTypeRepository

func NewResourceTypeRepository(db *gorm.DB) ResourceTypeRepository

NewResourceTypeRepository creates a new storage type.

type ResourceTypeScope

type ResourceTypeScope struct {
	gormsupport.Lifecycle

	// This is the primary key value
	ResourceTypeScopeID uuid.UUID `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key;column:resource_type_scope_id"`
	// The resource type that this scope belongs to
	ResourceType ResourceType `gorm:"ForeignKey:ResourceTypeID;AssociationForeignKey:ResourceTypeID"`
	// The foreign key value for ResourceType
	ResourceTypeID uuid.UUID
	// The name of this scope
	Name string
}

func (ResourceTypeScope) GetLastModified

func (m ResourceTypeScope) GetLastModified() time.Time

GetLastModified returns the last modification time

func (ResourceTypeScope) TableName

func (m ResourceTypeScope) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

type ResourceTypeScopeRepository

type ResourceTypeScopeRepository interface {
	CheckExists(ctx context.Context, id string) (bool, error)
	Create(ctx context.Context, u *ResourceTypeScope) error
	Save(ctx context.Context, u *ResourceTypeScope) error
	Delete(ctx context.Context, ID uuid.UUID) error
	Load(ctx context.Context, ID uuid.UUID) (*ResourceTypeScope, error)
	LookupForType(ctx context.Context, resourceTypeID uuid.UUID) ([]ResourceTypeScope, error)
	List(ctx context.Context, resourceType *ResourceType) ([]ResourceTypeScope, error)
	LookupByResourceTypeAndScope(ctx context.Context, resourceTypeID uuid.UUID, scopeName string) (*ResourceTypeScope, error)
}

ResourceTypeScopeRepository represents the storage interface.

func NewResourceTypeScopeRepository

func NewResourceTypeScopeRepository(db *gorm.DB) ResourceTypeScopeRepository

NewResourceTypeScopeRepository creates a new storage type.

Jump to

Keyboard shortcuts

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