principal

package
v0.0.0-...-b3f3fbb Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2015 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package principal provides principal-related logic

Index

Constants

View Source
const (
	PrincipalStatusActive   = "active"
	PrincipalStatusInactive = "inactive"
	PrincipalStatusDeleted  = "deleted"
)
View Source
const MetadataModel metadataModel = 0

representation of the metadata schema structure

Variables

View Source
var (
	ErrInvalidStatus     = errors.New("invalid status")
	ErrPrincipalInactive = errors.New("principal is inactive")
)
View Source
var (
	// ErrPrincipalNotFound is an error which various select methods will return
	// if the requested principal was not found
	ErrPrincipalNotFound = errors.New("principal not found")
)

Functions

func InsertPrincipalStatusTx

func InsertPrincipalStatusTx(db *sql.Tx, pr Principal, createdBy string) error

InsertPrincipalStatusTx adds a status entry for the given principal

func InsertPrincipalTx

func InsertPrincipalTx(db *sql.Tx, p *Principal) error

InsertPrincipalTx inserts a principal

This will modify the given principal, setting the ID field.

func PrincipalIDByNameTx

func PrincipalIDByNameTx(db *sql.Tx, name string) (int64, error)

Types

type Principal

type Principal struct {
	ID        int64 `json:",string"`
	Created   time.Time
	CreatedBy string
	Name      string `json:",omitempty"`

	Status string

	Metadata map[string]string
}

Principal represents a principal

A principal is a resource under which projects are organized

func PrincipalAllDB

func PrincipalAllDB(db *sql.DB) ([]*Principal, error)

func PrincipalByIDDB

func PrincipalByIDDB(db *sql.DB, id int64) (Principal, error)

func PrincipalByIDTx

func PrincipalByIDTx(db *sql.Tx, id int64) (Principal, error)

func PrincipalByNameDB

func PrincipalByNameDB(db *sql.DB, name string) (Principal, error)

PrincipalByNameDB selects a principal by the given name

If no such principal exists, it will return an empty principal

func PrincipalByNameTx

func PrincipalByNameTx(db *sql.Tx, name string) (Principal, error)

PrincipalByNameTx selects a principal by the given name

If no such principal exists, it will return an empty principal

func (Principal) Active

func (p Principal) Active() error

Active will return an error if the status is not "active" or invalid

func (Principal) Empty

func (p Principal) Empty() bool

Empty returns true if the principal is considered empty/uninitialized

func (Principal) ValidStatus

func (p Principal) ValidStatus() error

ValidStatus returns an ErrInvalidStatus if the set status is considered invalid

Jump to

Keyboard shortcuts

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