Documentation ¶
Index ¶
- Constants
- Variables
- func AbstractToModels(reg *Registry, abs string) (*GroupModel, *ResourceModel)
- func AnyToUInt(val any) (int, error)
- func ArrayContains(strs []string, needle string) bool
- func ArrayToLower(arr []string) []string
- func CleanArray(arr []string, full []string, text string) ([]string, error)
- func ConvertGroupContents(obj map[string]any, gm *GroupModel) error
- func ConvertRegistryContents(obj map[string]any, m *Model) error
- func ConvertResourceContents(obj map[string]any, rm *ResourceModel) error
- func ConvertStrToTime(str string) (time.Time, error)
- func ConvertString(val string, toType string) (any, bool)
- func ConvertVersionContents(obj map[string]any, rm *ResourceModel) error
- func CreateDB(name string) error
- func DBExists(name string) bool
- func DeleteDB(name string) error
- func Do(tx *Tx, cmd string, args ...interface{}) error
- func DoCount(tx *Tx, num int, cmd string, args ...interface{}) error
- func DoOne(tx *Tx, cmd string, args ...interface{}) error
- func DoOneTwo(tx *Tx, cmd string, args ...interface{}) error
- func DoZeroOne(tx *Tx, cmd string, args ...interface{}) error
- func DoZeroTwo(tx *Tx, cmd string, args ...interface{}) error
- func DumpTXs()
- func EnsureAttrOK(userAttr *Attribute, specAttr *Attribute) error
- func FindModelFile(name string) (string, error)
- func GenerateQuery(reg *Registry, what string, paths []string, filters [][]*FilterExpr) (string, []interface{}, error)
- func GetGroupModelInlines(gm *GroupModel) []string
- func GetJSONPointer(data any, path string) (any, error)
- func GetRegistryModelInlines(m *Model) []string
- func GetRegistryNames() []string
- func GetResourceModelInlines(rm *ResourceModel) []string
- func GetStack() []string
- func GetVersionModelInlines(rm *ResourceModel) []string
- func GoToOurType(val any) string
- func HTMLify(r *http.Request, buf []byte) []byte
- func HTTPDelete(info *RequestInfo) error
- func HTTPDeleteGroups(info *RequestInfo) error
- func HTTPDeleteResources(info *RequestInfo) error
- func HTTPDeleteVersions(info *RequestInfo) error
- func HTTPGETCapabilities(info *RequestInfo) error
- func HTTPGETContent(info *RequestInfo) error
- func HTTPGETModel(info *RequestInfo) error
- func HTTPGet(info *RequestInfo) error
- func HTTPPUTCapabilities(info *RequestInfo) error
- func HTTPPUTModel(info *RequestInfo) error
- func HTTPPutPost(info *RequestInfo) error
- func HTTPSetDefaultVersionID(info *RequestInfo) error
- func IncludeTraverse(includeArgs IncludeArgs, data map[string]any) error
- func IncomingObj2Map(incomingObj Object) (map[string]Object, error)
- func IsNil(a any) bool
- func IsOfType(val any, attrType string) bool
- func IsScalar(daType string) bool
- func IsString(daType string) bool
- func IsURL(str string) bool
- func IsValidAttributeName(name string) bool
- func IsValidMapKey(key string) bool
- func JSONEscape(obj interface{}) string
- func Keys(m interface{}) []string
- func KindIsScalar(k reflect.Kind) bool
- func LineNum(buf []byte, pos int) int
- func Match(pattern string, str string) bool
- func MaterializeProp(current any, pp *PropPath, val any, prev *PropPath) (any, error)
- func Model2xRegistryJson(m *Model, format string) ([]byte, error)
- func Must(err error)
- func NestedGetProp(obj any, pp *PropPath, prev *PropPath) (any, bool, error)
- func NewUUID() string
- func NormalizeStrTime(str string) (string, error)
- func NotNilBoolDef(val *any, def bool) bool
- func NotNilInt(val *any) int
- func NotNilIntDef(val *any, def int) int
- func NotNilString(val *any) string
- func ObjectGetProp(obj any, pp *PropPath) (any, bool, error)
- func ObjectSetProp(obj map[string]any, pp *PropPath, val any) error
- func OneLine(buf []byte) []byte
- func OpenDB(name string) error
- func PanicIf(b bool, msg string, args ...any)
- func Panicf(msg string, args ...any)
- func Path2Abstract(path string) string
- func PrepUpdateEntity(e *Entity) error
- func ProcessIncludes(file string, buf []byte, localFiles bool) ([]byte, error)
- func ProcessSetDefaultVersionIDFlag(info *RequestInfo, resource *Resource, version *Version) error
- func PtrBool(b bool) *bool
- func PtrBoolDef(val *any, def bool) *bool
- func PtrIntDef(val *any, def int) *int
- func RegHTMLify(r *http.Request, buf []byte) []byte
- func RegisterModelSerializer(name string, sm ModelSerializer)
- func RemoveComments(buf []byte) []byte
- func RemoveProps(buf []byte) []byte
- func RemoveResourceAttributes(singular string, obj map[string]any)
- func ReplaceVariables(str string) string
- func ResetMap[M ~map[K]V, K comparable, V any](m M, key K, oldVal V)
- func ResolvePath(baseFile string, next string) string
- func SerializeQuery(info *RequestInfo, paths []string, what string, filters [][]*FilterExpr) error
- func SerializeResourceContents(jw *JsonWriter, e *Entity, info *RequestInfo, extra *string) error
- func ShowStack()
- func SortedKeys(m interface{}) []string
- func SplitFragement(str string) (string, string)
- func StrTypes(types ...int) string
- func SubQuery(query string, args []interface{}) string
- func ToJSON(obj interface{}) string
- func ToJSONOneLine(obj interface{}) string
- func Unmarshal(buf []byte, v any) error
- func WildcardIt(str string) (string, bool)
- type AddType
- type AttrInternals
- type Attribute
- func (a *Attribute) AddAttr(name, daType string) (*Attribute, error)
- func (a *Attribute) AddAttrArray(name string, item *Item) (*Attribute, error)
- func (a *Attribute) AddAttrMap(name string, item *Item) (*Attribute, error)
- func (a *Attribute) AddAttrObj(name string) (*Attribute, error)
- func (a *Attribute) AddAttribute(attr *Attribute) (*Attribute, error)
- func (attr *Attribute) Clone(newName string) *Attribute
- func (a *Attribute) GetStrict() bool
- func (a *Attribute) InType(eType int) bool
- func (a *Attribute) IsScalar() bool
- func (a *Attribute) SetRegistry(reg *Registry)
- type Attributes
- func (attrs Attributes) AddIfValuesAttributes(obj map[string]any)
- func (attrs Attributes) ConvertStrings(obj Object)
- func (attrs Attributes) MarshalJSON() ([]byte, error)
- func (attrs Attributes) SetRegistry(reg *Registry)
- func (attrs Attributes) SetSpecPropsFields(singular string)
- func (attrs Attributes) Verify(ld *LevelData) error
- type BufferedWriter
- type Capabilities
- func (c *Capabilities) FlagEnabled(str string) bool
- func (c *Capabilities) MutableEnabled(str string) bool
- func (c *Capabilities) PaginationEnabled() bool
- func (c *Capabilities) SchemaEnabled(str string) bool
- func (c *Capabilities) ShortSelfEnabled(str string) bool
- func (c *Capabilities) SpecVersionEnabled(str string) bool
- func (c *Capabilities) Validate() error
- type DefaultWriter
- type DiscardWriter
- type Entity
- func (e *Entity) AddCalcProps(info *RequestInfo) map[string]any
- func (e *Entity) EnsureNewObject()
- func (e *Entity) Get(path string) any
- func (e *Entity) GetAsInt(path string) int
- func (e *Entity) GetAsString(path string) string
- func (e *Entity) GetAttributes(obj Object) Attributes
- func (e *Entity) GetBaseAttributes() Attributes
- func (e *Entity) GetCollections() [][2]string
- func (e *Entity) GetModels() (*GroupModel, *ResourceModel)
- func (e *Entity) GetPP(pp *PropPath) any
- func (e *Entity) Query(query string, args ...any) ([][]any, error)
- func (e *Entity) Refresh() error
- func (e *Entity) RemoveCollections(obj Object)
- func (e *Entity) Save() error
- func (e *Entity) SerializeProps(info *RequestInfo, ...) error
- func (e *Entity) SetDBProperty(pp *PropPath, val any) error
- func (e *Entity) SetFromDBName(name string, val *string, propType string) error
- func (e *Entity) SetPP(pp *PropPath, val any) error
- func (e *Entity) ToString() string
- func (e *Entity) Touch()
- func (e *Entity) Validate() error
- func (e *Entity) ValidateAndSave() error
- func (e *Entity) ValidateArray(val any, item *Item, path *PropPath) error
- func (e *Entity) ValidateAttribute(val any, attr *Attribute, path *PropPath) error
- func (e *Entity) ValidateMap(val any, item *Item, path *PropPath) error
- func (e *Entity) ValidateObject(val any, origAttrs Attributes, path *PropPath) error
- func (e *Entity) ValidateScalar(val any, attr *Attribute, path *PropPath) error
- type EntitySetter
- type EpochEntry
- type EpochEntryMap
- type FilterExpr
- type FilterPProf
- type Group
- func (g *Group) AddResource(rType string, id string, vID string) (*Resource, error)
- func (g *Group) AddResourceWithObject(rType string, id string, vID string, obj Object, doChildren bool, ...) (*Resource, error)
- func (g *Group) Delete() error
- func (g *Group) FindResource(rType string, id string, anyCase bool) (*Resource, error)
- func (g *Group) Get(name string) any
- func (g *Group) JustSet(name string, val any) error
- func (g *Group) SetCommit(name string, val any) error
- func (g *Group) SetSave(name string, val any) error
- func (g *Group) UpsertResource(rType string, id string, vID string) (*Resource, bool, error)
- func (g *Group) UpsertResourceWithObject(rType string, id string, vID string, obj Object, addType AddType, ...) (*Resource, bool, error)
- type GroupModel
- func (gm *GroupModel) AddAttr(name, daType string) (*Attribute, error)
- func (gm *GroupModel) AddAttrArray(name string, item *Item) (*Attribute, error)
- func (gm *GroupModel) AddAttrMap(name string, item *Item) (*Attribute, error)
- func (gm *GroupModel) AddAttrObj(name string) (*Attribute, error)
- func (gm *GroupModel) AddAttribute(attr *Attribute) (*Attribute, error)
- func (gm *GroupModel) AddLabel(name string, value string) error
- func (gm *GroupModel) AddResourceModel(plural string, singular string, maxVersions int, setVerId bool, ...) (*ResourceModel, error)
- func (gm *GroupModel) AddResourceModelFull(rm *ResourceModel) (*ResourceModel, error)
- func (gm *GroupModel) AddResourceModelSimple(plural, singular string) (*ResourceModel, error)
- func (gm *GroupModel) DelAttribute(name string) error
- func (gm *GroupModel) Delete() error
- func (gm *GroupModel) GetBaseAttributes() Attributes
- func (gm *GroupModel) RemoveLabel(name string) error
- func (gm *GroupModel) Save() error
- func (gm *GroupModel) SetRegistry(reg *Registry)
- func (gm *GroupModel) Verify(gmName string) error
- type HTTPWriter
- type IfValue
- type IfValues
- type IncludeArgs
- type Item
- func (i *Item) AddAttr(name, daType string) (*Attribute, error)
- func (i *Item) AddAttrArray(name string, item *Item) (*Attribute, error)
- func (i *Item) AddAttrMap(name string, item *Item) (*Attribute, error)
- func (i *Item) AddAttrObj(name string) (*Attribute, error)
- func (i *Item) AddAttribute(attr *Attribute) (*Attribute, error)
- func (i *Item) DelAttribute(name string) error
- func (i *Item) SetItem(item *Item) error
- func (i *Item) SetRegistry(reg *Registry)
- func (item *Item) Verify(path *PropPath) error
- type JsonWriter
- func (jw *JsonWriter) Indent()
- func (jw *JsonWriter) LoadCollections(eType int)
- func (jw *JsonWriter) NextEntity() (*Entity, error)
- func (jw *JsonWriter) OptPrintf(format string, args ...any)
- func (jw *JsonWriter) Outdent()
- func (jw *JsonWriter) Print(str string)
- func (jw *JsonWriter) Printf(format string, args ...any)
- func (jw *JsonWriter) WriteCollection() (int, error)
- func (jw *JsonWriter) WriteCollectionHeader(extra string) (string, error)
- func (jw *JsonWriter) WriteEntity() error
- func (jw *JsonWriter) WritePostCollections(extra string, eType int) string
- func (jw *JsonWriter) WritePreCollections(extra string, plural string, eType int) string
- type LevelData
- type Meta
- type Model
- func (m *Model) AddAttr(name, daType string) (*Attribute, error)
- func (m *Model) AddAttrArray(name string, item *Item) (*Attribute, error)
- func (m *Model) AddAttrMap(name string, item *Item) (*Attribute, error)
- func (m *Model) AddAttrObj(name string) (*Attribute, error)
- func (m *Model) AddAttribute(attr *Attribute) (*Attribute, error)
- func (m *Model) AddGroupModel(plural string, singular string) (*GroupModel, error)
- func (m *Model) AddLabel(name string, value string) error
- func (m *Model) ApplyNewModel(newM *Model) error
- func (m *Model) DelAttribute(name string) error
- func (m *Model) FindGroupModel(gTypePlural string) *GroupModel
- func (m *Model) GetBaseAttributes() Attributes
- func (m *Model) RemoveLabel(name string) error
- func (m *Model) Save() error
- func (m *Model) SetPointers()
- func (m *Model) SetSingular()
- func (m *Model) UnsetSingular()
- func (m *Model) Verify() error
- func (m *Model) VerifyAndSave() error
- type ModelSerializer
- type Object
- type PageWriter
- type PropPart
- type PropPath
- func MustPropPathFromDB(str string) *PropPath
- func MustPropPathFromPath(str string) *PropPath
- func MustPropPathFromUI(str string) *PropPath
- func NewPP() *PropPath
- func NewPPP(prop string) *PropPath
- func PropPathFromDB(str string) (*PropPath, error)
- func PropPathFromPath(str string) (*PropPath, error)
- func PropPathFromUI(str string) (*PropPath, error)
- func (pp *PropPath) Abstract() string
- func (pp *PropPath) Append(addPP *PropPath) *PropPath
- func (pp *PropPath) Clone() *PropPath
- func (pp *PropPath) DB() string
- func (pp *PropPath) Equals(other *PropPath) bool
- func (pp *PropPath) First() *PropPath
- func (pp *PropPath) HasPrefix(other *PropPath) bool
- func (pp *PropPath) I(i int) *PropPath
- func (pp *PropPath) Index(i int) *PropPath
- func (pp *PropPath) IsIndexed() int
- func (pp *PropPath) Len() int
- func (pp *PropPath) Next() *PropPath
- func (pp *PropPath) P(prop string) *PropPath
- func (pp *PropPath) Path() string
- func (pp *PropPath) Prop(prop string) *PropPath
- func (pp *PropPath) Top() string
- func (pp *PropPath) UI() string
- type RegOpt
- type Registry
- func (reg *Registry) AddGroup(gType string, id string) (*Group, error)
- func (reg *Registry) AddGroupWithObject(gType string, id string, obj Object, doChildren bool) (*Group, error)
- func (r *Registry) AddToCache(e *Entity)
- func (r *Registry) Commit() error
- func (reg *Registry) Delete() error
- func (reg *Registry) FindGroup(gType string, id string, anyCase bool) (*Group, error)
- func (reg *Registry) Get(name string) any
- func (reg *Registry) JustSet(name string, val any) error
- func (reg *Registry) LoadCapabilities() *Capabilities
- func (reg *Registry) LoadModel() *Model
- func (reg *Registry) LoadModelFromFile(file string) error
- func (r *Registry) Rollback() error
- func (r *Registry) SaveAllAndCommit() error
- func (r *Registry) SaveCommitRefresh() error
- func (reg *Registry) SetCommit(name string, val any) error
- func (reg *Registry) SetSave(name string, val any) error
- func (reg *Registry) Update(obj Object, addType AddType, doChildren bool) error
- func (reg *Registry) UpsertGroup(gType string, id string) (*Group, bool, error)
- func (reg *Registry) UpsertGroupWithObject(gType string, id string, obj Object, addType AddType, doChildren bool) (*Group, bool, error)
- type RequestInfo
- func (ri *RequestInfo) AddHeader(name, value string)
- func (info *RequestInfo) AddInline(path string) error
- func (info *RequestInfo) GetFlag(name string) string
- func (info *RequestInfo) GetFlagValues(name string) []string
- func (info *RequestInfo) HasFlag(name string) bool
- func (info *RequestInfo) IsInlineSet(entityPath string) bool
- func (info *RequestInfo) ParseFilters() error
- func (info *RequestInfo) ParseRequestURL() error
- func (info *RequestInfo) ShouldInline(entityPath string) bool
- func (ri *RequestInfo) Write(b []byte) (int, error)
- type Resource
- func (r *Resource) AddVersion(id string) (*Version, error)
- func (r *Resource) AddVersionWithObject(id string, obj Object) (*Version, error)
- func (r *Resource) Delete() error
- func (r *Resource) EnsureLatest() error
- func (r *Resource) EnsureMaxVersions() error
- func (r *Resource) FindMeta(anyCase bool) (*Meta, error)
- func (r *Resource) FindVersion(id string, anyCase bool) (*Version, error)
- func (r *Resource) Get(name string) any
- func (r *Resource) GetDefault() (*Version, error)
- func (r *Resource) GetNewest() (*Version, error)
- func (r *Resource) GetVersionIDs() ([]string, error)
- func (r *Resource) GetVersions() ([]*Version, error)
- func (r *Resource) GetXref() (string, *Resource, error)
- func (r *Resource) JustSet(name string, val any) error
- func (r *Resource) JustSetDefault(name string, val any) error
- func (r *Resource) JustSetMeta(name string, val any) error
- func (r *Resource) SetCommit(name string, val any) error
- func (r *Resource) SetCommitDefault(name string, val any) error
- func (r *Resource) SetCommitMeta(name string, val any) error
- func (r *Resource) SetDefault(newDefault *Version) error
- func (r *Resource) SetDefaultID(vID string) error
- func (r *Resource) SetSave(name string, val any) error
- func (r *Resource) SetSaveDefault(name string, val any) error
- func (r *Resource) SetSaveMeta(name string, val any) error
- func (r *Resource) SetSaveResource(name string, val any) error
- func (r *Resource) Touch()
- func (r *Resource) UpsertMetaWithObject(obj Object, addType AddType) (*Meta, bool, error)
- func (r *Resource) UpsertVersion(id string) (*Version, bool, error)
- func (r *Resource) UpsertVersionWithObject(id string, obj Object, addType AddType) (*Version, bool, error)
- type ResourceModel
- func (rm *ResourceModel) AddAttr(name, daType string) (*Attribute, error)
- func (rm *ResourceModel) AddAttrArray(name string, item *Item) (*Attribute, error)
- func (rm *ResourceModel) AddAttrMap(name string, item *Item) (*Attribute, error)
- func (rm *ResourceModel) AddAttrObj(name string) (*Attribute, error)
- func (rm *ResourceModel) AddAttribute(attr *Attribute) (*Attribute, error)
- func (rm *ResourceModel) AddLabel(name string, value string) error
- func (rm *ResourceModel) AddMetaAttr(name, daType string) (*Attribute, error)
- func (rm *ResourceModel) AddMetaAttrArray(name string, item *Item) (*Attribute, error)
- func (rm *ResourceModel) AddMetaAttrMap(name string, item *Item) (*Attribute, error)
- func (rm *ResourceModel) AddMetaAttrObj(name string) (*Attribute, error)
- func (rm *ResourceModel) AddMetaAttribute(attr *Attribute) (*Attribute, error)
- func (rm *ResourceModel) AddTypeMap(ct string, format string) error
- func (rm *ResourceModel) DelAttribute(name string) error
- func (rm *ResourceModel) DelMetaAttribute(name string) error
- func (rm *ResourceModel) Delete() error
- func (rm *ResourceModel) GetBaseAttributes() Attributes
- func (rm *ResourceModel) GetBaseMetaAttributes() Attributes
- func (rm *ResourceModel) GetHasDocument() bool
- func (rm *ResourceModel) GetSetDefaultSticky() bool
- func (rm *ResourceModel) GetSetVersionId() bool
- func (rm *ResourceModel) MapContentType(ct string) string
- func (rm *ResourceModel) RemoveLabel(name string) error
- func (rm *ResourceModel) RemoveTypeMap(ct string) error
- func (rm *ResourceModel) Save() error
- func (rm *ResourceModel) SetMaxVersions(maxV int) error
- func (rm *ResourceModel) SetRegistry(reg *Registry)
- func (rm *ResourceModel) SetSetDefaultSticky(val bool) error
- func (r *ResourceModel) UnmarshalJSON(data []byte) error
- func (rm *ResourceModel) Verify(rmName string) error
- func (rm *ResourceModel) VerifyAndSave() error
- func (rm *ResourceModel) VerifyData() error
- type Result
- type Server
- type Tx
- func (tx *Tx) AddGroup(g *Group)
- func (tx *Tx) AddMeta(m *Meta)
- func (tx *Tx) AddRegistry(r *Registry)
- func (tx *Tx) AddResource(r *Resource)
- func (tx *Tx) AddToCache(e *Entity)
- func (tx *Tx) AddVersion(v *Version)
- func (tx *Tx) Commit() error
- func (tx *Tx) Conditional(err error) error
- func (tx *Tx) GetGroup(r *Registry, plural string, gID string) *Group
- func (tx *Tx) GetMeta(r *Resource) *Meta
- func (tx *Tx) GetRegistry(rID string) *Registry
- func (tx *Tx) GetResource(g *Group, plural string, rID string) *Resource
- func (tx *Tx) GetVersion(r *Resource, vID string) *Version
- func (tx *Tx) NewTx() error
- func (tx *Tx) Prepare(query string) (*sql.Stmt, error)
- func (tx *Tx) RemoveFromCache(e *Entity)
- func (tx *Tx) Rollback() error
- func (tx *Tx) SaveAllAndCommit() error
- func (tx *Tx) SaveCommitRefresh() error
- func (tx *Tx) String() string
- func (tx *Tx) WriteCache(force bool) error
- type Version
- func (v *Version) Delete() error
- func (v *Version) DeleteSetNextVersion(nextVersionID string) error
- func (v *Version) Get(name string) any
- func (v *Version) JustDelete() error
- func (v *Version) JustSet(name string, val any) error
- func (v *Version) SetCommit(name string, val any) error
- func (v *Version) SetDefault() error
- func (v *Version) SetSave(name string, val any) error
Constants ¶
const ( // NEVER ADD TO THE MIDDLE - ALWAYS TO THE END ENTITY_REGISTRY = iota ENTITY_GROUP ENTITY_RESOURCE ENTITY_META ENTITY_VERSION ENTITY_MODEL )
const ANY = "any"
Attribute types
const ARRAY = "array"
const BOOLEAN = "boolean"
const DB_IN = ','
If DB_IN changes then DefaultProps in init.sql needs to change too
const DB_INDEX = '#'
const DECIMAL = "decimal"
const HASDOCUMENT = true
const HTML_EXP = "▾" // Expanded json symbol for HTML output
const HTML_MIN = "▸" // Minimized json symbol for HTML output
const INTEGER = "integer"
const IN_CHAR = '.'
const IN_STR = string(IN_CHAR)
const MAP = "map"
const MAXVERSIONS = 0
const OBJECT = "object"
const READONLY = false
const SETDEFAULTSTICKY = true
const SETVERSIONID = true
const SPECVERSION = "0.5"
const STRICT = true
Model attribute default values
const STRING = "string"
const TIMESTAMP = "timestamp"
const UINTEGER = "uinteger"
const URI = "uri"
const URI_REFERENCE = "urireference"
const URI_TEMPLATE = "uritemplate"
const URL = "url"
const UX_IN = '.'
const XREGSCHEMA = "xRegistry-json"
Variables ¶
var AllowableFlags = ArrayToLower([]string{
"epoch", "export", "filter", "inline",
"nested", "nodefaultversionid", "nodefaultversionsticky",
"noepoch", "noreadonly", "schema", "setdefaultversionid"})
var AllowableMutable = ArrayToLower([]string{
"capabilities", "entities", "model"})
var AllowableSchemas = ArrayToLower([]string{XREGSCHEMA + "/" + SPECVERSION})
var AllowableSpecVersions = ArrayToLower([]string{"0.5"})
var DB *sql.DB
var DBHOST = "localhost"
var DBPASSWORD = "password"
var DBPORT = "3306"
var DBUSER = "root"
var DB_InitFunc func()
var DB_Name = ""
var DefaultCapabilities = &Capabilities{ Flags: AllowableFlags, Mutable: AllowableMutable, Pagination: false, Schemas: AllowableSchemas, ShortSelf: false, SpecVersions: AllowableSpecVersions, }
var DefaultDiscardWriter = &DiscardWriter{}
var DefaultRegDbSID string
var DefinedTypes = map[string]bool{ ANY: true, BOOLEAN: true, DECIMAL: true, INTEGER: true, UINTEGER: true, ARRAY: true, MAP: true, OBJECT: true, STRING: true, TIMESTAMP: true, URI: true, URI_REFERENCE: true, URI_TEMPLATE: true, URL: true}
var GitCommit = "<n/a>"
var JPtrEsc0 = regexp.MustCompile(`~0`)
var JPtrEsc1 = regexp.MustCompile(`~1`)
var MAX_VARCHAR = 512
var ModelSerializers = map[string]ModelSerializer{}
var OrderedSpecProps = []*Attribute{ { Name: "specversion", Type: STRING, ReadOnly: true, Immutable: true, ServerRequired: true, // contains filtered or unexported fields }, { Name: "id", Type: STRING, Immutable: true, ServerRequired: true, // contains filtered or unexported fields }, { Name: "versionid", Type: STRING, Immutable: true, ServerRequired: true, // contains filtered or unexported fields }, { Name: "self", Type: URL, ReadOnly: true, ServerRequired: true, // contains filtered or unexported fields }, { Name: "xid", Type: URL, ReadOnly: true, ServerRequired: true, // contains filtered or unexported fields }, { Name: "xref", Type: URL, // contains filtered or unexported fields }, { Name: "epoch", Type: UINTEGER, ServerRequired: true, // contains filtered or unexported fields }, { Name: "name", Type: STRING, // contains filtered or unexported fields }, { Name: "isdefault", Type: BOOLEAN, ReadOnly: true, // contains filtered or unexported fields }, { Name: "description", Type: STRING, // contains filtered or unexported fields }, { Name: "documentation", Type: URL, // contains filtered or unexported fields }, { Name: "labels", Type: MAP, Item: &Item{ Type: STRING, }, // contains filtered or unexported fields }, { Name: "createdat", Type: TIMESTAMP, ServerRequired: true, // contains filtered or unexported fields }, { Name: "modifiedat", Type: TIMESTAMP, ServerRequired: true, // contains filtered or unexported fields }, { Name: "contenttype", Type: STRING, // contains filtered or unexported fields }, { Name: "$extensions", // contains filtered or unexported fields }, { Name: "$space", // contains filtered or unexported fields }, { Name: "$resource", // contains filtered or unexported fields }, { Name: "metaurl", Type: URL, ReadOnly: true, ServerRequired: true, // contains filtered or unexported fields }, { Name: "$space", // contains filtered or unexported fields }, { Name: "defaultversionid", Type: STRING, ServerRequired: true, // contains filtered or unexported fields }, { Name: "defaultversionurl", Type: URL, ReadOnly: true, ServerRequired: true, // contains filtered or unexported fields }, { Name: "defaultversionsticky", Type: BOOLEAN, ReadOnly: true, // contains filtered or unexported fields }, { Name: "$space", // contains filtered or unexported fields }, { Name: "capabilities", Type: OBJECT, ReadOnly: false, Attributes: Attributes{ "*": &Attribute{ Name: "*", Type: ANY, }, }, // contains filtered or unexported fields }, { Name: "model", Type: OBJECT, ReadOnly: true, Attributes: Attributes{ "*": &Attribute{ Name: "*", Type: ANY, }, }, // contains filtered or unexported fields }, }
This allows for us to choose the order and define custom logic per prop
var PProfFilter = &FilterPProf{}
var RegexpMapKey = regexp.MustCompile("^[a-z0-9][a-z0-9_.\\-]{0,62}$")
var RegexpPropName = regexp.MustCompile("^[a-z_][a-z0-9_./]{0,62}$")
var SpecProps = map[string]*Attribute{}
var TESTING = (os.Getenv("TESTING") != "")
var TXs = map[string]*Tx{}
Active transaction - mainly for debugging and testing
var TXsMutex = sync.RWMutex{}
Functions ¶
func AbstractToModels ¶
func AbstractToModels(reg *Registry, abs string) (*GroupModel, *ResourceModel)
func ArrayContains ¶
func ArrayToLower ¶
func ConvertGroupContents ¶
func ConvertGroupContents(obj map[string]any, gm *GroupModel) error
Find all Resources/Versions in 'obj' and make sure their RESOURCE attribute is converted into a byte array
func ConvertRegistryContents ¶
Find all Groups/Resources/Versions in 'obj' and make sure their RESOURCE attribute is converted into a byte array
func ConvertResourceContents ¶
func ConvertResourceContents(obj map[string]any, rm *ResourceModel) error
Convert the RESOURCE attribute from JSON to a byte array, if present. Then do any Versions in the "versions" collection, if there.
func ConvertVersionContents ¶
func ConvertVersionContents(obj map[string]any, rm *ResourceModel) error
Convert the RESOURCE attribute from JSON to a byte array, if present.
func EnsureAttrOK ¶
Make sure that the attribute doesn't deviate too much from the spec defined version of it. There's only so much that we allow the user to customize
func FindModelFile ¶
func GenerateQuery ¶
func GetGroupModelInlines ¶
func GetGroupModelInlines(gm *GroupModel) []string
func GetRegistryModelInlines ¶
func GetRegistryNames ¶
func GetRegistryNames() []string
func GetResourceModelInlines ¶
func GetResourceModelInlines(rm *ResourceModel) []string
func GetVersionModelInlines ¶
func GetVersionModelInlines(rm *ResourceModel) []string
func GoToOurType ¶
func HTTPDelete ¶
func HTTPDelete(info *RequestInfo) error
func HTTPDeleteGroups ¶
func HTTPDeleteGroups(info *RequestInfo) error
func HTTPDeleteResources ¶
func HTTPDeleteResources(info *RequestInfo) error
func HTTPDeleteVersions ¶
func HTTPDeleteVersions(info *RequestInfo) error
func HTTPGETCapabilities ¶
func HTTPGETCapabilities(info *RequestInfo) error
func HTTPGETContent ¶
func HTTPGETContent(info *RequestInfo) error
func HTTPGETModel ¶
func HTTPGETModel(info *RequestInfo) error
func HTTPGet ¶
func HTTPGet(info *RequestInfo) error
func HTTPPUTCapabilities ¶
func HTTPPUTCapabilities(info *RequestInfo) error
func HTTPPUTModel ¶
func HTTPPUTModel(info *RequestInfo) error
func HTTPPutPost ¶
func HTTPPutPost(info *RequestInfo) error
func HTTPSetDefaultVersionID ¶
func HTTPSetDefaultVersionID(info *RequestInfo) error
func IncludeTraverse ¶
func IncludeTraverse(includeArgs IncludeArgs, data map[string]any) error
data is the current map to check for $include statements
func IsValidAttributeName ¶
func IsValidMapKey ¶
func JSONEscape ¶
func JSONEscape(obj interface{}) string
func KindIsScalar ¶
func MaterializeProp ¶
func Model2xRegistryJson ¶
The model serializer we use for the "xRegistry" schema format
func NestedGetProp ¶
Value, Found, Error
func NormalizeStrTime ¶
func NotNilBoolDef ¶
func NotNilIntDef ¶
func NotNilString ¶
func ObjectGetProp ¶
Value, Found, Error
func ObjectSetProp ¶
Given a PropPath and a value this will add the necessary golang data structures to 'obj' to materialize PropPath and set the appropriate fields to 'val'
func Path2Abstract ¶
func PrepUpdateEntity ¶
func ProcessIncludes ¶
func ProcessSetDefaultVersionIDFlag ¶
func ProcessSetDefaultVersionIDFlag(info *RequestInfo, resource *Resource, version *Version) error
Process the ?setdefaultversionid query parameter "resource" is the resource we're processing "version" is the version that was processed
func PtrBoolDef ¶
func RegisterModelSerializer ¶
func RegisterModelSerializer(name string, sm ModelSerializer)
func RemoveComments ¶
func RemoveProps ¶
func RemoveResourceAttributes ¶
Remove any attributes that appear on Resources but not Versions. Mainly used to prep an Obj that was directed at a Resource but will be used to update a Version
func ReplaceVariables ¶
func ResetMap ¶
func ResetMap[M ~map[K]V, K comparable, V any](m M, key K, oldVal V)
Either delete or change the value of a map based on "oldVal" being nil or not
func ResolvePath ¶
func SerializeQuery ¶
func SerializeQuery(info *RequestInfo, paths []string, what string, filters [][]*FilterExpr) error
func SerializeResourceContents ¶
func SerializeResourceContents(jw *JsonWriter, e *Entity, info *RequestInfo, extra *string) error
func SortedKeys ¶
func SortedKeys(m interface{}) []string
func SplitFragement ¶
func ToJSONOneLine ¶
func ToJSONOneLine(obj interface{}) string
func WildcardIt ¶
Types ¶
type AttrInternals ¶
type AttrInternals struct {
// contains filtered or unexported fields
}
Defined a separate struct instead of just inlining these attributes so that we can just copy them over in one statement in SetSpecPropsFields() and so that if we add more we don't need to remember to update that func
type Attribute ¶
type Attribute struct { Registry *Registry `json:"-"` Name string `json:"name,omitempty"` Type string `json:"type,omitempty"` Description string `json:"description,omitempty"` Enum []any `json:"enum,omitempty"` // just scalars though Strict *bool `json:"strict,omitempty"` ReadOnly bool `json:"readonly,omitempty"` Immutable bool `json:"immutable,omitempty"` ClientRequired bool `json:"clientrequired,omitempty"` ServerRequired bool `json:"serverrequired,omitempty"` Default any `json:"default,omitempty"` Attributes Attributes `json:"attributes,omitempty"` // for Objs Item *Item `json:"item,omitempty"` // for maps & arrays IfValues IfValues `json:"ifValues,omitempty"` // Value // contains filtered or unexported fields }
Do not include "omitempty" on any attribute that has a default value that doesn't match golang's default value for that type. E.g. bool defaults to 'false', but Strict needs to default to 'true'. See the custome Unmarshal funcs in model.go for how we set those
func CalcSpecProps ¶
func (*Attribute) AddAttrArray ¶
func (*Attribute) AddAttrMap ¶
func (*Attribute) AddAttribute ¶
func (*Attribute) SetRegistry ¶
type Attributes ¶
func (Attributes) AddIfValuesAttributes ¶
func (attrs Attributes) AddIfValuesAttributes(obj map[string]any)
This just does the top-level attributes with the assumption that we'll do the lower-level ones later on in Entity.ValidateObject
func (Attributes) ConvertStrings ¶
func (attrs Attributes) ConvertStrings(obj Object)
func (Attributes) MarshalJSON ¶
func (attrs Attributes) MarshalJSON() ([]byte, error)
func (Attributes) SetRegistry ¶
func (attrs Attributes) SetRegistry(reg *Registry)
func (Attributes) SetSpecPropsFields ¶
func (attrs Attributes) SetSpecPropsFields(singular string)
Copy the internal data for spec defined properties so we can access that info directly from these Attributes instead of having to go back to the SpecProps stuff
func (Attributes) Verify ¶
func (attrs Attributes) Verify(ld *LevelData) error
type BufferedWriter ¶
type BufferedWriter struct { Info *RequestInfo OldWriter HTTPWriter Headers *map[string]string Buffer *bytes.Buffer }
func NewBufferedWriter ¶
func NewBufferedWriter(info *RequestInfo) *BufferedWriter
func (*BufferedWriter) AddHeader ¶
func (bw *BufferedWriter) AddHeader(name, value string)
func (*BufferedWriter) Done ¶
func (bw *BufferedWriter) Done()
type Capabilities ¶
type Capabilities struct { Flags []string `json:"flags"` Mutable []string `json:"mutable"` Pagination bool `json:"pagination"` Schemas []string `json:"schemas"` ShortSelf bool `json:"shortself"` SpecVersions []string `json:"specversions"` }
func ParseCapabilitiesJSON ¶
func ParseCapabilitiesJSON(buf []byte) (*Capabilities, error)
func (*Capabilities) FlagEnabled ¶
func (c *Capabilities) FlagEnabled(str string) bool
func (*Capabilities) MutableEnabled ¶
func (c *Capabilities) MutableEnabled(str string) bool
func (*Capabilities) PaginationEnabled ¶
func (c *Capabilities) PaginationEnabled() bool
func (*Capabilities) SchemaEnabled ¶
func (c *Capabilities) SchemaEnabled(str string) bool
func (*Capabilities) ShortSelfEnabled ¶
func (c *Capabilities) ShortSelfEnabled(str string) bool
func (*Capabilities) SpecVersionEnabled ¶
func (c *Capabilities) SpecVersionEnabled(str string) bool
func (*Capabilities) Validate ¶
func (c *Capabilities) Validate() error
type DefaultWriter ¶
type DefaultWriter struct {
Info *RequestInfo
}
func (*DefaultWriter) AddHeader ¶
func (dw *DefaultWriter) AddHeader(name, value string)
func (*DefaultWriter) Done ¶
func (dw *DefaultWriter) Done()
type DiscardWriter ¶
type DiscardWriter struct{}
func (*DiscardWriter) AddHeader ¶
func (dw *DiscardWriter) AddHeader(name, value string)
func (*DiscardWriter) Done ¶
func (dw *DiscardWriter) Done()
type Entity ¶
type Entity struct { Registry *Registry `json:"-"` DbSID string // Entity's SID Plural string Singular string UID string // Entity's UID Object map[string]any `json:"-"` NewObject map[string]any `json:"-"` // updated version, save() will store // These were added just for convenience and so we can use the same // struct for traversing the SQL results Type int // ENTITY_REGISTRY(0)/GROUP(1)/RESOURCE(2)/VERSION(3)/... Path string // [GROUPS/gID[/RESOURCES/rID[/versions/vID]]] Abstract string // [GROUPS[/RESOURCES[/versions]]] EpochSet bool `json:"-"` // Has epoch been updated this transaction? ModSet bool `json:"-"` // Has modifiedat been updated this transaction? Self any `json:"-"` // Pointer to typed Entity (e.g. *Resource) // contains filtered or unexported fields }
func RawEntitiesFromQuery ¶
func RawEntityFromPath ¶
func (*Entity) AddCalcProps ¶
func (e *Entity) AddCalcProps(info *RequestInfo) map[string]any
This will add in the calculated properties into the entity. This will normally be called after a query using FullTree view and before we serialize the entity we need to add the non-DB-stored properties (meaning, the calculated ones. Note that we make a copy and don't touch the entity itself. Serializing an entity shouldn't have side-effects.
func (*Entity) EnsureNewObject ¶
func (e *Entity) EnsureNewObject()
func (*Entity) GetAsString ¶
func (*Entity) GetAttributes ¶
func (e *Entity) GetAttributes(obj Object) Attributes
func (*Entity) GetBaseAttributes ¶
func (e *Entity) GetBaseAttributes() Attributes
Returns the initial set of attributes defined for the entity.
func (*Entity) GetCollections ¶
Array of plural/singular pairs
func (*Entity) GetModels ¶
func (e *Entity) GetModels() (*GroupModel, *ResourceModel)
func (*Entity) Refresh ¶
Update the entity's Object - not the other props in Entity. Similar to RawEntityFromPath
func (*Entity) RemoveCollections ¶
This will remove all Collection related attributes from the entity. While this is an Entity.Func, we allow callers to pass in the Object data to use instead of the e.Object/NewObject so that we'll use this Entity's Type (which tells us which collections it has), on the 'obj'. This is handy for cases where we need to remove the Resource's collections from a Version's Object - like on a PUT to /GROUPs/gID/RESOURECEs/rID where we're passing in what looks like a Resource entity, but we're really using it to create a Version
func (*Entity) SerializeProps ¶
func (e *Entity) SerializeProps(info *RequestInfo, fn func(*Entity, *RequestInfo, string, any, *Attribute) error) error
This is used to serialize an Entity regardless of the format. This will:
- Use AddCalcProps() to fill in any missing props (eg Entity's getFn())
- Call that passed-in 'fn' to serialize each prop but in the right order as defined by OrderedSpecProps
func (*Entity) SetDBProperty ¶
This will save a single property/value in the DB. This assumes the caller is traversing the Object and splitting it into individual props
func (*Entity) SetFromDBName ¶
This is used to take a DB entry and update the current Entity's Object
func (*Entity) SetPP ¶
This is really just an internal Setter used for testing. It'll set a property and then validate and save the entity in the DB
func (*Entity) Validate ¶
Doesn't fully validate in the sense that it'll assume read-only fields are not worth checking since the server generated them. This is mainly used for validating input from a client. NOTE!!! This isn't a read-only operation. Normally it would be, but to avoid traversing the entity more than once, we will tweak things if needed. For example, if a missing attribute has a Default value then we'll add it.
func (*Entity) ValidateAndSave ¶
func (*Entity) ValidateArray ¶
func (*Entity) ValidateAttribute ¶
func (*Entity) ValidateMap ¶
func (*Entity) ValidateObject ¶
func (e *Entity) ValidateObject(val any, origAttrs Attributes, path *PropPath) error
This should be called after all type-specific calculated properties have been removed - such as collections
type EntitySetter ¶
type EpochEntry ¶
type EpochEntryMap ¶
type EpochEntryMap map[string]EpochEntry
func LoadEpochMap ¶
func LoadEpochMap(info *RequestInfo) (EpochEntryMap, error)
type FilterExpr ¶
type FilterPProf ¶
type FilterPProf struct {
// contains filtered or unexported fields
}
type Group ¶
func (*Group) AddResource ¶
func (*Group) AddResourceWithObject ¶
func (*Group) FindResource ¶
func (*Group) UpsertResource ¶
type GroupModel ¶
type GroupModel struct { SID string `json:"-"` Registry *Registry `json:"-"` Plural string `json:"plural"` Singular string `json:"singular"` Labels map[string]string `json:"labels,omitempty"` Attributes Attributes `json:"attributes,omitempty"` Resources map[string]*ResourceModel `json:"resources,omitempty"` // Plural }
func (*GroupModel) AddAttrArray ¶
func (gm *GroupModel) AddAttrArray(name string, item *Item) (*Attribute, error)
func (*GroupModel) AddAttrMap ¶
func (gm *GroupModel) AddAttrMap(name string, item *Item) (*Attribute, error)
func (*GroupModel) AddAttrObj ¶
func (gm *GroupModel) AddAttrObj(name string) (*Attribute, error)
func (*GroupModel) AddAttribute ¶
func (gm *GroupModel) AddAttribute(attr *Attribute) (*Attribute, error)
func (*GroupModel) AddResourceModel ¶
func (gm *GroupModel) AddResourceModel(plural string, singular string, maxVersions int, setVerId bool, setDefaultSticky bool, hasDocument bool) (*ResourceModel, error)
func (*GroupModel) AddResourceModelFull ¶
func (gm *GroupModel) AddResourceModelFull(rm *ResourceModel) (*ResourceModel, error)
func (*GroupModel) AddResourceModelSimple ¶
func (gm *GroupModel) AddResourceModelSimple(plural, singular string) (*ResourceModel, error)
func (*GroupModel) DelAttribute ¶
func (gm *GroupModel) DelAttribute(name string) error
func (*GroupModel) Delete ¶
func (gm *GroupModel) Delete() error
func (*GroupModel) GetBaseAttributes ¶
func (gm *GroupModel) GetBaseAttributes() Attributes
func (*GroupModel) RemoveLabel ¶
func (gm *GroupModel) RemoveLabel(name string) error
func (*GroupModel) Save ¶
func (gm *GroupModel) Save() error
func (*GroupModel) SetRegistry ¶
func (gm *GroupModel) SetRegistry(reg *Registry)
func (*GroupModel) Verify ¶
func (gm *GroupModel) Verify(gmName string) error
type HTTPWriter ¶
func DefaultHTTPWriter ¶
func DefaultHTTPWriter(info *RequestInfo) HTTPWriter
type IfValue ¶
type IfValue struct {
SiblingAttributes Attributes `json:"siblingAttributes,omitempty"`
}
type IfValues ¶
func (IfValues) SetRegistry ¶
type IncludeArgs ¶
type Item ¶
type Item struct { Registry *Registry `json:"-"` Type string `json:"type,omitempty"` Attributes Attributes `json:"attributes,omitempty"` // when 'type'=obj Item *Item `json:"item,omitempty"` // when 'type'=map,array }
func NewItemArray ¶
func NewItemMap ¶
func NewItemObject ¶
func NewItemObject() *Item
func NewItemType ¶
func (*Item) AddAttrArray ¶
func (*Item) DelAttribute ¶
func (*Item) SetRegistry ¶
type JsonWriter ¶
type JsonWriter struct { Entity *Entity // Current row in the DB results // contains filtered or unexported fields }
func NewJsonWriter ¶
func NewJsonWriter(info *RequestInfo, results *Result) *JsonWriter
func (*JsonWriter) Indent ¶
func (jw *JsonWriter) Indent()
func (*JsonWriter) LoadCollections ¶
func (jw *JsonWriter) LoadCollections(eType int)
func (*JsonWriter) NextEntity ¶
func (jw *JsonWriter) NextEntity() (*Entity, error)
func (*JsonWriter) OptPrintf ¶
func (jw *JsonWriter) OptPrintf(format string, args ...any)
func (*JsonWriter) Outdent ¶
func (jw *JsonWriter) Outdent()
func (*JsonWriter) Print ¶
func (jw *JsonWriter) Print(str string)
func (*JsonWriter) Printf ¶
func (jw *JsonWriter) Printf(format string, args ...any)
func (*JsonWriter) WriteCollection ¶
func (jw *JsonWriter) WriteCollection() (int, error)
func (*JsonWriter) WriteCollectionHeader ¶
func (jw *JsonWriter) WriteCollectionHeader(extra string) (string, error)
func (*JsonWriter) WriteEntity ¶
func (jw *JsonWriter) WriteEntity() error
func (*JsonWriter) WritePostCollections ¶
func (jw *JsonWriter) WritePostCollections(extra string, eType int) string
func (*JsonWriter) WritePreCollections ¶
func (jw *JsonWriter) WritePreCollections(extra string, plural string, eType int) string
type Model ¶
type Model struct { Registry *Registry `json:"-"` Labels map[string]string `json:"labels,omitempty"` Attributes Attributes `json:"attributes,omitempty"` Groups map[string]*GroupModel `json:"groups,omitempty"` // Plural }
func (*Model) AddAttrArray ¶
func (*Model) AddGroupModel ¶
func (m *Model) AddGroupModel(plural string, singular string) (*GroupModel, error)
func (*Model) ApplyNewModel ¶
func (*Model) DelAttribute ¶
func (*Model) FindGroupModel ¶
func (m *Model) FindGroupModel(gTypePlural string) *GroupModel
func (*Model) GetBaseAttributes ¶
func (m *Model) GetBaseAttributes() Attributes
func (*Model) RemoveLabel ¶
func (*Model) SetPointers ¶
func (m *Model) SetPointers()
func (*Model) SetSingular ¶
func (m *Model) SetSingular()
Total hack. Need a way to pass in the Singular and eType info from the model down into the serialization routines.
func (*Model) UnsetSingular ¶
func (m *Model) UnsetSingular()
func (*Model) VerifyAndSave ¶
VerifyAndSave() should be called by automatically but there may be cases where someone would need to call it manually (e.g. setting an attribute's property - we should technically find a way to catch those cases so code above this shouldn't need to think about it
type ModelSerializer ¶
func GetModelSerializer ¶
func GetModelSerializer(format string) ModelSerializer
type Object ¶
func ExtractIncomingObject ¶
func ExtractIncomingObject(info *RequestInfo, body []byte) (Object, error)
type PageWriter ¶
type PageWriter struct { Info *RequestInfo OldWriter HTTPWriter Headers *map[string]string Buffer *bytes.Buffer }
func NewPageWriter ¶
func NewPageWriter(info *RequestInfo) *PageWriter
func (*PageWriter) AddHeader ¶
func (pw *PageWriter) AddHeader(name, value string)
func (*PageWriter) Done ¶
func (pw *PageWriter) Done()
type PropPath ¶
type PropPath struct {
Parts []PropPart
}
func MustPropPathFromDB ¶
func MustPropPathFromPath ¶
func MustPropPathFromUI ¶
func PropPathFromDB ¶
func PropPathFromPath ¶
func PropPathFromUI ¶
type Registry ¶
type Registry struct { Entity Capabilities *Capabilities Model *Model }
func GetDefaultReg ¶
func (*Registry) AddGroupWithObject ¶
func (*Registry) AddToCache ¶
ONLY CALL FROM TESTS - NEVER IN PROD
func (*Registry) LoadCapabilities ¶
func (reg *Registry) LoadCapabilities() *Capabilities
func (*Registry) LoadModelFromFile ¶
func (*Registry) SaveAllAndCommit ¶
func (*Registry) SaveCommitRefresh ¶
ONLY CALL FROM TESTS - NEVER IN PROD
func (*Registry) UpsertGroup ¶
*Group, isNew, error
type RequestInfo ¶
type RequestInfo struct { Registry *Registry BaseURL string OriginalPath string OriginalRequest *http.Request `json:"-"` OriginalResponse http.ResponseWriter `json:"-"` Parts []string Root string Abstract string GroupType string GroupUID string GroupModel *GroupModel ResourceType string ResourceUID string ResourceModel *ResourceModel VersionUID string What string // Registry, Coll, Entity HasNested bool Inlines []string // TODO store a PropPaths instead Filters [][]*FilterExpr // [OR][AND] filter=e,e(and) &(or) filter=e ShowStructure bool // was $structure present StatusCode int SentStatus bool HTTPWriter HTTPWriter `json:"-"` // contains filtered or unexported fields }
func ParseRequest ¶
func ParseRequest(tx *Tx, w http.ResponseWriter, r *http.Request) (*RequestInfo, error)
func (*RequestInfo) AddHeader ¶
func (ri *RequestInfo) AddHeader(name, value string)
func (*RequestInfo) AddInline ¶
func (info *RequestInfo) AddInline(path string) error
func (*RequestInfo) GetFlag ¶
func (info *RequestInfo) GetFlag(name string) string
Get query parameter value
func (*RequestInfo) GetFlagValues ¶
func (info *RequestInfo) GetFlagValues(name string) []string
func (*RequestInfo) HasFlag ¶
func (info *RequestInfo) HasFlag(name string) bool
func (*RequestInfo) IsInlineSet ¶
func (info *RequestInfo) IsInlineSet(entityPath string) bool
func (*RequestInfo) ParseFilters ¶
func (info *RequestInfo) ParseFilters() error
func (*RequestInfo) ParseRequestURL ¶
func (info *RequestInfo) ParseRequestURL() error
func (*RequestInfo) ShouldInline ¶
func (info *RequestInfo) ShouldInline(entityPath string) bool
type Resource ¶
func (*Resource) AddVersionWithObject ¶
func (*Resource) EnsureLatest ¶
func (*Resource) EnsureMaxVersions ¶
func (*Resource) FindVersion ¶
Maybe replace error with a panic? same for other finds??
func (*Resource) GetDefault ¶
Maybe replace error with a panic?
func (*Resource) GetVersionIDs ¶
func (*Resource) GetVersions ¶
func (*Resource) SetDefault ¶
Only call this if you want things to be sticky (when not nil). Creating a new version should do this directly
func (*Resource) SetDefaultID ¶
Note will set sticky if vID != ""
func (*Resource) SetSaveResource ¶
Should only ever be used for "id"
func (*Resource) UpsertMetaWithObject ¶
*Meta, isNew, error
func (*Resource) UpsertVersion ¶
type ResourceModel ¶
type ResourceModel struct { SID string `json:"-"` GroupModel *GroupModel `json:"-"` Plural string `json:"plural"` Singular string `json:"singular"` MaxVersions int `json:"maxversions"` // do not include omitempty SetVersionId *bool `json:"setversionid"` // do not include omitempty SetDefaultSticky *bool `json:"setdefaultversionsticky"` // do not include omitempty HasDocument *bool `json:"hasdocument"` // do not include omitempty ReadOnly bool `json:"readonly,omitempty"` TypeMap map[string]string `json:"typemap,omitempty"` Labels map[string]string `json:"labels,omitempty"` Attributes Attributes `json:"attributes,omitempty"` MetaAttributes Attributes `json:"metaattributes,omitempty"` }
func (*ResourceModel) AddAttr ¶
func (rm *ResourceModel) AddAttr(name, daType string) (*Attribute, error)
func (*ResourceModel) AddAttrArray ¶
func (rm *ResourceModel) AddAttrArray(name string, item *Item) (*Attribute, error)
func (*ResourceModel) AddAttrMap ¶
func (rm *ResourceModel) AddAttrMap(name string, item *Item) (*Attribute, error)
func (*ResourceModel) AddAttrObj ¶
func (rm *ResourceModel) AddAttrObj(name string) (*Attribute, error)
func (*ResourceModel) AddAttribute ¶
func (rm *ResourceModel) AddAttribute(attr *Attribute) (*Attribute, error)
func (*ResourceModel) AddMetaAttr ¶
func (rm *ResourceModel) AddMetaAttr(name, daType string) (*Attribute, error)
func (*ResourceModel) AddMetaAttrArray ¶
func (rm *ResourceModel) AddMetaAttrArray(name string, item *Item) (*Attribute, error)
func (*ResourceModel) AddMetaAttrMap ¶
func (rm *ResourceModel) AddMetaAttrMap(name string, item *Item) (*Attribute, error)
func (*ResourceModel) AddMetaAttrObj ¶
func (rm *ResourceModel) AddMetaAttrObj(name string) (*Attribute, error)
func (*ResourceModel) AddMetaAttribute ¶
func (rm *ResourceModel) AddMetaAttribute(attr *Attribute) (*Attribute, error)
func (*ResourceModel) AddTypeMap ¶
func (rm *ResourceModel) AddTypeMap(ct string, format string) error
func (*ResourceModel) DelAttribute ¶
func (rm *ResourceModel) DelAttribute(name string) error
func (*ResourceModel) DelMetaAttribute ¶
func (rm *ResourceModel) DelMetaAttribute(name string) error
func (*ResourceModel) Delete ¶
func (rm *ResourceModel) Delete() error
func (*ResourceModel) GetBaseAttributes ¶
func (rm *ResourceModel) GetBaseAttributes() Attributes
func (*ResourceModel) GetBaseMetaAttributes ¶
func (rm *ResourceModel) GetBaseMetaAttributes() Attributes
func (*ResourceModel) GetHasDocument ¶
func (rm *ResourceModel) GetHasDocument() bool
func (*ResourceModel) GetSetDefaultSticky ¶
func (rm *ResourceModel) GetSetDefaultSticky() bool
func (*ResourceModel) GetSetVersionId ¶
func (rm *ResourceModel) GetSetVersionId() bool
func (*ResourceModel) MapContentType ¶
func (rm *ResourceModel) MapContentType(ct string) string
Map incoming "contentType" (ct) to its typemap value. If there is no match (or more than one match with a different type) then default to "binary"
func (*ResourceModel) RemoveLabel ¶
func (rm *ResourceModel) RemoveLabel(name string) error
func (*ResourceModel) RemoveTypeMap ¶
func (rm *ResourceModel) RemoveTypeMap(ct string) error
func (*ResourceModel) Save ¶
func (rm *ResourceModel) Save() error
func (*ResourceModel) SetMaxVersions ¶
func (rm *ResourceModel) SetMaxVersions(maxV int) error
func (*ResourceModel) SetRegistry ¶
func (rm *ResourceModel) SetRegistry(reg *Registry)
func (*ResourceModel) SetSetDefaultSticky ¶
func (rm *ResourceModel) SetSetDefaultSticky(val bool) error
func (*ResourceModel) UnmarshalJSON ¶
func (r *ResourceModel) UnmarshalJSON(data []byte) error
func (*ResourceModel) Verify ¶
func (rm *ResourceModel) Verify(rmName string) error
func (*ResourceModel) VerifyAndSave ¶
func (rm *ResourceModel) VerifyAndSave() error
func (*ResourceModel) VerifyData ¶
func (rm *ResourceModel) VerifyData() error
type Result ¶
type Result struct { Data []*any // One row TempData []any Reuse bool AllRows [][]*any // contains filtered or unexported fields }
func (*Result) PullNextRow ¶
func (r *Result) PullNextRow()
func (*Result) RetrieveAllRowsFromDB ¶
func (r *Result) RetrieveAllRowsFromDB()
func (*Result) RetrieveNextRowFromDB ¶
type Tx ¶
type Tx struct { Registry *Registry CreateTime string // use for entity timestamps too User string IgnoreEpoch bool IgnoreDefaultVersionSticky bool IgnoreDefaultVersionID bool // Cache of entities this Tx is dealing with. Things can get funky if // we have more than one instance of the same entity in memory. // TODO DUG expand this to save all types, not just Versions. // Also, consider having Commit() just automatically call ValidateAndSave // for all entities in the Tx - then people don't need to call save // explicitly Cache map[string]*Entity // e.Path // contains filtered or unexported fields }
Holds info about the current transaction. In a lot of ways this is similar to golang's Context in that it holds other info related to the current changes that are going on. Maybe one day convert this to a Context where Tx is just as apsect of it.
func (*Tx) AddRegistry ¶
func (*Tx) AddResource ¶
func (*Tx) AddToCache ¶
func (*Tx) AddVersion ¶
func (*Tx) Conditional ¶
func (*Tx) GetRegistry ¶
func (*Tx) NewTx ¶
It's ok for this to be called multiple times for the same Tx just to make sure we have an active transaction - it's a no-op at that point
func (*Tx) RemoveFromCache ¶
func (*Tx) SaveAllAndCommit ¶
func (*Tx) WriteCache ¶
type Version ¶
func (*Version) DeleteSetNextVersion ¶
func (*Version) JustDelete ¶
JustDelete will delete the Version w/o any additional logic like "defaultversionid" manipulation. Used when xref on the Resource is set.