model

package
v0.0.0-...-1256ada Latest Latest
Warning

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

Go to latest
Published: May 25, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HighPriority   AlertPriority = "high"
	NormalPriority AlertPriority = "normal"
	LowPriority    AlertPriority = "low"

	NewStatus      AlertStatus = "new"
	SeenStatus     AlertStatus = "seen"
	ArchivedStatus AlertStatus = "archived"
)

Variables

This section is empty.

Functions

func BoltGetAccountObjects

func BoltGetAccountObjects(db *bolt.DB, accountUUID ParentID, bucketName string, t reflect.Type) (*map[string]PersistanceID, error)

TODO rename to GetChildObjects

func BoltGetObject

func BoltGetObject(db *bolt.DB, bucketName string, objID string, t reflect.Type) (*PersistanceID, *ParentID, error)

BoltGetObject returns the object with the given 'objID' and the accountID it belongs to or nil if none is found

func BoltGetObjects

func BoltGetObjects(db *bolt.DB, bucketName string, t reflect.Type) (*map[string][]PersistanceID, error)

func BoltMap

func BoltMap(objs interface{}) *map[string]PersistanceID

func BoltSaveAccountObjects

func BoltSaveAccountObjects(db *bolt.DB, accountUUID ParentID, bucketName string, objs *map[string]PersistanceID) error

TODO rename to SaveChildObjects

func BoltSaveObject

func BoltSaveObject(bucket *bolt.Bucket, key string, obj interface{}) error

func BoltSingle

func BoltSingle(obj interface{}) *map[string]PersistanceID

func LatestHeartbeatPerApiKey

func LatestHeartbeatPerApiKey(db *bolt.DB, accountUUID string) (*map[string]Heartbeat, error)

func ListAPIKeys

func ListAPIKeys(db *bolt.DB, accountUUID string) (*map[string]APIKey, error)

ListAPIKeys returns all API keys for the given account

func ListAccounts

func ListAccounts(db *bolt.DB) (*map[string]Account, error)

ListAccounts returns all accounts in a map with the uuid as key

func ListAlerts

func ListAlerts(db *bolt.DB, accountUUID string) (*map[string]Alert, error)

ListsAlerts returns all alerts for the given account

func ListAllTokens

func ListAllTokens(db *bolt.DB) (*map[string][]Token, error)

ListAllTokens returns a map of account id to array of tokens

func ListDevices

func ListDevices(db *bolt.DB, accountUUID string) (*map[string]Device, error)

func ListHeartbeats

func ListHeartbeats(db *bolt.DB, accountUUID string) (*map[string]Heartbeat, error)

func ListNonArchivedAlerts

func ListNonArchivedAlerts(db *bolt.DB, accountUUID string) (*map[string]Alert, error)

ListNonArchivedAlerts list all alerts that do not have status "archived" for the given account

func ListRenewals

func ListRenewals(db *bolt.DB, accountUUID string) (*map[string]Renewal, error)

func ListTokens

func ListTokens(db *bolt.DB, accountUUID string) (*map[string]Token, error)

ListTokens returns all created tokens for an account as a map with the token id as key and the token as value

func SaveDevices

func SaveDevices(db *bolt.DB, accountUUID string, devices *map[string]Device) error

func SaveRenewals

func SaveRenewals(db *bolt.DB, accountUUID string, renewals *map[string]Renewal) error

Types

type APIKey

type APIKey struct {
	ID          string // uuid
	Description string // the user's description of the key
	Status      APIKeyStatus
	CreatedAt   time.Time
}

APIKey contains information about a created API key

func GetAPIKey

func GetAPIKey(db *bolt.DB, apiKeyID string) (*APIKey, *string, error)

GetAPIKey returns the API Key with the given id and the account id it belongs to

func NewAPIKey

func NewAPIKey() *APIKey

NewAPIKey creates a new API key

func (APIKey) PersistanceID

func (a APIKey) PersistanceID() string

PersistanceID is used by the persistance layer

func (APIKey) Save

func (a APIKey) Save(db *bolt.DB, accountUUID string) error

type APIKeyStatus

type APIKeyStatus string

APIKeyStatus shows the status of the API Key

const (
	// APIKeyActive indicates that this API key is active
	APIKeyActive APIKeyStatus = "active"
	// APIKeyInactive indicates that this API key is inactive
	APIKeyInactive = "inactive"
)

type Account

type Account struct {
	ID        string // uuid
	CreatedAt time.Time
}

func GetAccount

func GetAccount(db *bolt.DB, uuid string) (*Account, error)

func NewAccount

func NewAccount() *Account

func (*Account) APIKeys

func (account *Account) APIKeys(db *bolt.DB) (*map[string]APIKey, error)

APIKeys returns all api keys for the account

func (*Account) Alerts

func (account *Account) Alerts(db *bolt.DB) (*map[string]Alert, error)

Alerts returns the alerts for the account

func (*Account) Save

func (account *Account) Save(db *bolt.DB) error

Save saves the account

type Alert

type Alert struct {
	ID               string // uuid
	APIKeyID         string // uuid of api key that sent this heartbeat
	Title            string
	ShortDescription string
	LongDescription  string
	Priority         AlertPriority
	Status           AlertStatus
	TriggeredAt      time.Time
	CreatedAt        time.Time
	UpdatedAt        time.Time
}

func GetAlert

func GetAlert(db *bolt.DB, alertID string) (*Alert, *string, error)

GetAlert returns the alert with the given id and the account id it belongs to

func NewAlert

func NewAlert(apiKeyID string) *Alert

NewAlert creates a new Alert. APIKeyID is mandatory

func (Alert) PersistanceID

func (a Alert) PersistanceID() string

func (Alert) Save

func (a Alert) Save(db *bolt.DB, accountUUID string) error

Save the alert attached to the given accountUUID

type AlertPriority

type AlertPriority string

AlertPriority shows the priority of the alert, possible values HighPriority, NormalPriority and LowPriority

type AlertStatus

type AlertStatus string

AlertStatus indicates the status of the alert

type ChildID

type ChildID string

type Device

type Device struct {
	ID         string // uuid
	DeviceID   string
	DeviceType string
	DeviceInfo string
	CreatedAt  time.Time
}

func NewDevice

func NewDevice() *Device

func (Device) PersistanceID

func (d Device) PersistanceID() string

type Heartbeat

type Heartbeat struct {
	ID         string // uuid
	APIKeyID   string // uuid of api key that sent this heartbeat
	ExecutedAt time.Time
	CreatedAt  time.Time
}

func NewHeartbeat

func NewHeartbeat(apiKeyID string) *Heartbeat

func (Heartbeat) PersistanceID

func (h Heartbeat) PersistanceID() string

func (Heartbeat) Save

func (h Heartbeat) Save(db *bolt.DB, accountUUID string) error

type ParentID

type ParentID string

type PersistanceID

type PersistanceID interface {
	PersistanceID() string
}

type Renewal

type Renewal struct {
	ID             string     // uuid
	RefreshTokenID string     // uuid of refresh token
	UsedAt         *time.Time // the time at which this renewal was used to create a new access token
	CreatedAt      time.Time  // the time at which this renewal was created
}

func GetRenewal

func GetRenewal(db *bolt.DB, renewalID string) (*Renewal, *string, error)

GetRenewal returns the given renewal and accountID if a match is found, nil otherwise

func NewRenewal

func NewRenewal() *Renewal

func (Renewal) PersistanceID

func (r Renewal) PersistanceID() string

func (Renewal) Save

func (r Renewal) Save(db *bolt.DB, accountUUID string) error

type Scope

type Scope struct {
	Roles        []string // maps to roles
	Capabilities []string // maps to capabilities
}

type Token

type Token struct {
	ID        string    // uuid, maps to jti
	IssueTime time.Time // maps to iat
	Type      string    // maps to type
	Scope     Scope
	RawString string // the raw base64 encoded token data string
	CreatedAt time.Time
}

func NewToken

func NewToken() *Token

func (Token) PersistanceID

func (t Token) PersistanceID() string

func (Token) Save

func (t Token) Save(db *bolt.DB, accountUUID string) error

Jump to

Keyboard shortcuts

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