schema

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EntryIDFromKey

func EntryIDFromKey(key string) util.OID

EntryIDFromKey returns entry' ID from key

func EntryKey

func EntryKey(ID util.OID) string

EntryKey returns the entry's db key

func FileBlobKey

func FileBlobKey(ID util.OID) string

FileBlobKey returns file blob' key

func FileIDFromKey

func FileIDFromKey(key string) util.OID

FileIDFromKey returns file' ID from key

func FileKey

func FileKey(ID util.OID) string

FileKey returns the file's db key

func InitIndex

func InitIndex(DB *buntdb.DB)

InitIndex ...

func SecretKey

func SecretKey(ID util.OID) string

SecretKey returns the secret's db key

func ShareIDFromKey

func ShareIDFromKey(key string) util.OID

ShareIDFromKey returns share' ID from key

func ShareKey

func ShareKey(ID util.OID) string

ShareKey returns the share's db key

func TeamIDFromKey

func TeamIDFromKey(key string) util.OID

TeamIDFromKey returns team' ID from key

func TeamKey

func TeamKey(ID util.OID) string

TeamKey returns the team's db key

func UserKey

func UserKey(name string) string

UserKey returns the user's db key

Types

type Entry

type Entry struct {
	TeamID    util.OID  `json:"teamID"`
	Name      string    `json:"name"`
	Category  string    `json:"category"`
	Priority  int       `json:"priority"`
	IsDeleted bool      `json:"isDeleted"`
	Secrets   []string  `json:"secrets"`
	Shares    []string  `json:"shares"`
	Files     []string  `json:"files"`
	Created   time.Time `json:"created"`
	Updated   time.Time `json:"updated"`
}

Entry represents entry info

func EntryFrom

func EntryFrom(str string) (*Entry, error)

EntryFrom parse JSON string and returns a Entry intance.

func (*Entry) AddFile

func (e *Entry) AddFile(fileID string) bool

AddFile adds the file to the entry

func (*Entry) AddSecret

func (e *Entry) AddSecret(secretID string) bool

AddSecret adds the secret to the entry

func (*Entry) HasFile

func (e *Entry) HasFile(fileID string) bool

HasFile returns whether the entry has the file

func (*Entry) HasSecret

func (e *Entry) HasSecret(secretID string) bool

HasSecret returns whether the entry has the secret

func (*Entry) RemoveFile

func (e *Entry) RemoveFile(fileID string) bool

RemoveFile removes the file from the entry

func (*Entry) RemoveSecret

func (e *Entry) RemoveSecret(secretID string) bool

RemoveSecret removes the secret from the entry

func (*Entry) Result

func (e *Entry) Result(ID util.OID, secrets []*SecretResult, shares []*ShareResult) *EntryResult

Result returns EntryResult intance

func (*Entry) String

func (e *Entry) String() string

String returns JSON string with full entry info

func (*Entry) Summary

func (e *Entry) Summary(ID util.OID) *EntrySum

Summary returns EntrySum intance

type EntryResult

type EntryResult struct {
	ID       util.OID        `json:"id"`
	TeamID   util.OID        `json:"teamID"`
	Name     string          `json:"name"`
	Category string          `json:"category"`
	Priority int             `json:"priority"`
	Secrets  []*SecretResult `json:"secrets"`
	Files    []*FileResult   `json:"files"`
	Shares   []*ShareResult  `json:"shares"`
	Created  time.Time       `json:"created"`
	Updated  time.Time       `json:"updated"`
}

EntryResult represents desensitized entry

func (*EntryResult) String

func (e *EntryResult) String() string

String returns JSON string with desensitized entry info

type EntrySum

type EntrySum struct {
	ID       util.OID  `json:"id"`
	TeamID   util.OID  `json:"teamID"`
	Name     string    `json:"name"`
	Category string    `json:"category"`
	Priority int       `json:"priority"`
	Created  time.Time `json:"created"`
	Updated  time.Time `json:"updated"`
}

EntrySum represents desensitized entry

func (*EntrySum) String

func (e *EntrySum) String() string

String returns JSON string with desensitized entry info

type File

type File struct {
	Name    string    `json:"name"`
	UserID  string    `json:"userID"`
	Created time.Time `json:"created"`
	Updated time.Time `json:"updated"`
}

File represents file

func FileFrom

func FileFrom(str string) (file *File, err error)

FileFrom parse JSON string and returns a File intance.

func (*File) Result

func (f *File) Result(ID util.OID, signed string) *FileResult

Result returns FileResult intance

func (*File) String

func (f *File) String() string

String returns JSON string with full file info

type FileBlob

type FileBlob []byte // binary data encoded with base64, size <= 100KB

FileBlob ...

func FileBlobFromString

func FileBlobFromString(text string) (FileBlob, error)

FileBlobFromString ...

func (FileBlob) Reader

func (b FileBlob) Reader() *bytes.Reader

Reader returns a Reader instance

func (FileBlob) String

func (b FileBlob) String() string

MarshalText ...

type FileResult

type FileResult struct {
	ID      util.OID  `json:"id"`
	UserID  string    `json:"userID"`
	Name    string    `json:"name"`
	Signed  string    `json:"signed"`
	Created time.Time `json:"created"`
	Updated time.Time `json:"updated"`
}

FileResult represents file info

type Secret

type Secret struct {
	Name    string    `json:"name"`
	URL     string    `json:"url"`
	Pass    string    `json:"password"`
	Note    string    `json:"note"`
	Created time.Time `json:"created"`
	Updated time.Time `json:"updated"`
}

Secret represents secret info

func SecretFrom

func SecretFrom(str string) (*Secret, error)

SecretFrom parse JSON string and returns a Secret intance.

func (*Secret) Result

func (s *Secret) Result(id util.OID) *SecretResult

Result returns EntryResult intance

func (*Secret) String

func (s *Secret) String() string

String returns JSON string with full secret info

type SecretResult

type SecretResult struct {
	ID      util.OID  `json:"id"`
	Name    string    `json:"name"`
	URL     string    `json:"url"`
	Pass    string    `json:"password"`
	Note    string    `json:"note"`
	Created time.Time `json:"created"`
	Updated time.Time `json:"updated"`
}

SecretResult represents secret info

func (*SecretResult) String

func (s *SecretResult) String() string

String returns JSON string with full secret info

type Share

type Share struct {
	TeamID  util.OID  `json:"teamID"`
	EntryID util.OID  `json:"entryID"`
	Name    string    `json:"name"`
	Token   string    `json:"Token"`
	UserID  string    `json:"userID"`
	Created time.Time `json:"created"`
	Updated time.Time `json:"updated"`
}

Share represents share info

func ShareFrom

func ShareFrom(str string) (*Share, error)

ShareFrom parse JSON string and returns a Share intance.

func (*Share) Result

func (s *Share) Result(ID util.OID) *ShareResult

Result returns ShareResult intance

func (*Share) String

func (s *Share) String() string

String returns JSON string with full share info

type ShareResult

type ShareResult struct {
	ID      util.OID  `json:"id"`
	TeamID  util.OID  `json:"teamID"`
	EntryID util.OID  `json:"entryID"`
	UserID  string    `json:"userID"`
	Name    string    `json:"name"`
	Created time.Time `json:"created"`
	Updated time.Time `json:"updated"`
}

ShareResult represents desensitized share

type StringSlice

type StringSlice []string

StringSlice ...

func (StringSlice) Add

func (s StringSlice) Add(str string) ([]string, bool)

Add adds the str to the slice.

func (StringSlice) Has

func (s StringSlice) Has(str string) bool

Has returns whether the str is in the slice.

func (StringSlice) Remove

func (s StringSlice) Remove(str string) ([]string, bool)

Remove remove the str from the slice.

type Team

type Team struct {
	UserID     string    `json:"userID"`
	Name       string    `json:"name"`
	Pass       string    `json:"pass"`
	IsFrozen   bool      `json:"isFrozen"` // if true, member can't modify team's entires
	IsDeleted  bool      `json:"isDeleted"`
	Visibility string    `json:"visibility"` // enum: "private", "member"
	Members    []string  `json:"members"`
	Created    time.Time `json:"created"`
	Updated    time.Time `json:"updated"`
}

Team represents team info

func TeamFrom

func TeamFrom(str string) (*Team, error)

TeamFrom parse JSON string and returns a Team intance.

func (*Team) AddMember

func (t *Team) AddMember(userID string) bool

AddMember adds the user to team's members

func (*Team) HasMember

func (t *Team) HasMember(userID string) bool

HasMember returns whether the user is team's member

func (*Team) RemoveMember

func (t *Team) RemoveMember(userID string) bool

RemoveMember removes the user from team's members

func (*Team) Result

func (t *Team) Result(ID util.OID) *TeamResult

Result returns TeamResult intance

func (*Team) String

func (t *Team) String() string

String returns JSON string with full team info

type TeamResult

type TeamResult struct {
	ID         util.OID  `json:"id"`
	UserID     string    `json:"userID"`
	Name       string    `json:"name"`
	IsFrozen   bool      `json:"isFrozen"`
	IsPrivate  bool      `json:"IsPrivate"`
	Visibility string    `json:"visibility"`
	Members    []string  `json:"members"`
	Created    time.Time `json:"created"`
	Updated    time.Time `json:"updated"`
}

TeamResult represents desensitized team

func (*TeamResult) String

func (t *TeamResult) String() string

String returns JSON string with desensitized team info

type User

type User struct {
	ID        string    `json:"id"`
	Pass      string    `json:"pass"` // encrypt
	Avatar    util.OID  `json:"avatar"`
	IsBlocked bool      `json:"isBlocked"`
	Attempt   int       `json:"attempt"` // login attempts
	Created   time.Time `json:"created"`
	Updated   time.Time `json:"updated"`
}

User represents user info

func UserFrom

func UserFrom(str string) (*User, error)

UserFrom parse JSON string and returns a User intance.

func (*User) Result

func (u *User) Result() *UserResult

Result returns UserResult intance

func (*User) String

func (u *User) String() string

String returns JSON string with full user info

type UserResult

type UserResult struct {
	ID      string    `json:"id"`
	Avatar  util.OID  `json:"avatar"`
	Created time.Time `json:"created"`
	Updated time.Time `json:"updated"`
}

UserResult represents desensitized user

func (*UserResult) String

func (u *UserResult) String() string

String returns JSON string with desensitized user info

Jump to

Keyboard shortcuts

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