Documentation ¶
Index ¶
- Constants
- func FieldAsTypedInterface(field string, val string) (interface{}, error)
- func IsValidLogField(field string) bool
- type Collection
- type Filters
- type HookResult
- type JSONSchemaObject
- type Log
- type MetaData
- type Op
- type Project
- type ProjectAPIKey
- type ProjectDetail
- type ProjectUser
- type ResourceDefinition
- func (def *ResourceDefinition) GetSchema() (*JSONSchemaObject, error)
- func (def *ResourceDefinition) GetSchemaMap() (map[string]interface{}, error)
- func (def *ResourceDefinition) MarshalJSON() ([]byte, error)
- func (def *ResourceDefinition) UnmarshalJSON(b []byte) error
- func (def *ResourceDefinition) Validate() error
- type ResourceObject
- type RootKey
- type Session
- type Stats
- type Tier
- type TranslatedError
- type User
- type Value
- type WebHook
Constants ¶
const ( EndpointResource string = "resource" EndpointJSON string = "json" )
const ( // CreatorUser constant CreatorUser = "user" // CreatorAPIKey constant CreatorAPIKey = "apikey" )
Variables ¶
This section is empty.
Functions ¶
func FieldAsTypedInterface ¶
FieldAsTypedInterface returns the field value as an interface with the proper type
func IsValidLogField ¶
IsValidLogField verifies that a field exists for the `Log` object
Types ¶
type Collection ¶
type Collection struct { ID string `json:"id"` Name string `json:"name"` ParallelRead bool `json:"parallel_read"` ParallelWrite bool `json:"parallel_write"` Create bool `json:"create"` Read bool `json:"read"` Update bool `json:"update"` Delete bool `json:"delete"` Created time.Time `json:"created"` Items int64 `json:"items"` }
Collection is a mongo collection containing whatever data a user wants to save
func (*Collection) Validate ¶
func (c *Collection) Validate() error
Validate validates the collection fields
type HookResult ¶
type HookResult struct { WebHookID string `json:"webhook_id"` ProjectID string `json:"project_id"` StatusCode int `json:"status_code"` ResponseTime int64 `json:"response_time"` ErrorMessage string `json:"error_message"` Created time.Time `json:"created"` }
HookResult contains relevant information regarding the http response of a web hook
type JSONSchemaObject ¶
type JSONSchemaObject struct { Type string `json:"type"` Properties map[string]map[string]interface{} `json:"properties"` Required []string `json:"required"` }
JSONSchemaObject is a simplified representation of the root schema
type Log ¶
type Log struct { ID string `json:"id"` ProjectID string `json:"project_id"` EndpointType string `json:"endpoint_type"` Verb string `json:"verb"` Path string `json:"path"` StatusCode int `json:"status_code"` Created int64 `json:"created"` AlignedCreated int64 `json:"aligned"` ResponseTime int64 `json:"response_time"` Initiator string `json:"initiator"` InitiatorType string `json:"initiator_type"` InitiatorID string `json:"initiator_id"` TargetID string `json:"target_id"` }
Log is any user/api key initiated event that should be recorded
type MetaData ¶
type MetaData struct { Creator string `json:"creator"` CreatorType string `json:"creator_type"` Created int64 `json:"created"` }
MetaData contains internal data about a collection/resource object.
func NewMetaData ¶
NewMetaData returns a pointer to a new MetaData object with the `Created` field set to now.
type Project ¶
type Project struct { ID string `json:"id"` UserID string `json:"user_id"` Slug string `json:"slug"` Name string `json:"name"` Description string `json:"description"` Icon string `json:"icon"` Created time.Time `json:"created"` Authn bool `json:"authn"` UserRegistration bool `json:"user_registration"` }
Project is an application project created and managed by a `User`
type ProjectAPIKey ¶
type ProjectAPIKey struct { ID string `json:"id"` ProjectID string `json:"project_id"` KeyHash string `json:"-"` Created time.Time `json:"created"` Description string `json:"description"` Read bool `json:"read"` Write bool `json:"write"` Role string `json:"role"` }
ProjectAPIKey is a static key used to access resources and collections of the project
type ProjectDetail ¶
type ProjectDetail struct { ID string `json:"id"` UserID string `json:"user_id"` Slug string `json:"slug"` Name string `json:"name"` Description string `json:"description"` Icon string `json:"icon"` Created time.Time `json:"created"` Authn bool `json:"authn"` UserRegistration bool `json:"user_registration"` Requests int `json:"requests"` Hooks []*WebHook `json:"hooks"` }
ProjectDetail is read from the app_project_limits view and contains app tier values based on the currently active account tier
type ProjectUser ¶
type ProjectUser struct { ID string `json:"id"` ProjectID string `json:"project_id"` Username string `json:"username"` Email string `json:"email"` PasswordHash string `json:"-"` Created time.Time `json:"created"` Read bool `json:"read"` Write bool `json:"write"` Role string `json:"role"` }
ProjectUser is a user of a project. A user can access resources and collections of the project.
type ResourceDefinition ¶
type ResourceDefinition struct { ID string `json:"id"` // ID is the unique identifier for this resource definition ProjectID string `json:"project_id"` Title string `json:"title"` // Title of this resource PathName string `json:"path_name"` // PathName is the name that will appear in the URL path ParallelRead bool `json:"parallel_read"` ParallelWrite bool `json:"parallel_write"` Create bool `json:"create"` Read bool `json:"read"` Update bool `json:"update"` Delete bool `json:"delete"` Created time.Time `json:"created"` // Created is the timestamp the resource was created Schema string `json:"schema"` // Properties is the string representation of the JSON schema properties }
ResourceDefinition defines an API resource
func (*ResourceDefinition) GetSchema ¶
func (def *ResourceDefinition) GetSchema() (*JSONSchemaObject, error)
GetSchema returns the schema as a `Schema` object
func (*ResourceDefinition) GetSchemaMap ¶
func (def *ResourceDefinition) GetSchemaMap() (map[string]interface{}, error)
GetSchemaMap returns the schema as a `map[string]interface{}`
func (*ResourceDefinition) MarshalJSON ¶
func (def *ResourceDefinition) MarshalJSON() ([]byte, error)
MarshalJSON custom marshaller to marshall properties to json
func (*ResourceDefinition) UnmarshalJSON ¶
func (def *ResourceDefinition) UnmarshalJSON(b []byte) error
UnmarshalJSON is a custom unmarshaller
func (*ResourceDefinition) Validate ¶
func (def *ResourceDefinition) Validate() error
Validate validates the fields of a resource definition.
type ResourceObject ¶
type ResourceObject map[string]interface{}
ResourceObject is a custom type which wraps a map[string]interface
func (*ResourceObject) Validate ¶
func (obj *ResourceObject) Validate(definition *ResourceDefinition) error
Validate validates that the object matches the schema
type RootKey ¶
type RootKey struct { ID string `json:"id"` Key string `json:"key"` ProjectID string `json:"project_id"` Create bool `json:"create"` Read bool `json:"read"` Update bool `json:"update"` Delete bool `json:"delete"` }
RootKey defines the metadata of a project root JSON key
type Session ¶
type Session struct { ID string `json:"id"` ProjectID string `json:"project_id"` UserID string `json:"user_id"` Location string `json:"location"` Mobile bool `json:"mobile"` IP string `json:"ip"` LastAccessed time.Time `json:"last_accessed"` Browser string `json:"browser"` OS string `json:"os"` }
Session is a user session model for either the mgmt application or a project
type Stats ¶
Stats is a struct that contains the size and count of objects in a Resource or Collection
type Tier ¶
type Tier struct { ID string `json:"id"` Name string `json:"name"` Cost string `json:"cost"` Requests int `json:"requests"` Projects int `json:"projects"` Storage int `json:"storage"` }
Tier is an application tier, describing the limitations of an application subscribed to a certain tier
type TranslatedError ¶
TranslatedError is a database error translated with HTTP Status code
func NewTranslatedError ¶
func NewTranslatedError(code int, err error) *TranslatedError
NewTranslatedError returns a pointer to a new `TranslatedError`
func (*TranslatedError) Error ¶
func (t *TranslatedError) Error() string
type User ¶
type User struct { ID string `json:"id"` Username string `json:"username"` Email string `json:"email"` PasswordHash string `json:"-"` Created time.Time `json:"created"` Tier string `json:"app_tier"` Active bool `json:"active"` Admin bool `json:"-"` }
User is a user of the application
type WebHook ¶
type WebHook struct { ID string `json:"id"` ProjectID string `json:"project_id"` Label string `json:"label"` IsEnabled bool `json:"is_enabled"` Entity string `json:"entity"` EntityID string `json:"entity_id"` HookEvent string `json:"event"` Headers []byte `json:"headers"` HookURL string `json:"hook_url"` }
WebHook defines the structure of a project web hook
func (*WebHook) MarshalJSON ¶
MarshalJSON custom marshaller to marshall properties to json
func (*WebHook) UnmarshalJSON ¶
UnmarshalJSON is a custom unmarshaller, specificall for the `headers`