Documentation
¶
Overview ¶
Package fosp provides primitives for FOSP client and server implementations.
Code example:
srv := NewServer(dbDriver, domain)
Index ¶
- Constants
- func IsPermission(perm string) bool
- func NegatePermission(perm string) string
- type AccessControlEntry
- type AccessControlList
- type Attachment
- type Message
- type Notification
- type Object
- func (o *Object) Patch(patch PatchObject) error
- func (o *Object) PermissionsForAcl(user string, groups ...string) *PermissionSet
- func (o *Object) PermissionsForChildren(user string, groups ...string) *PermissionSet
- func (o *Object) PermissionsForData(user string, groups ...string) *PermissionSet
- func (o *Object) PermissionsForSubscriptions(user string, groups ...string) *PermissionSet
- func (o *Object) ReducedACL() *AccessControlList
- type PatchObject
- type Patchable
- type PermissionSet
- func (ps *PermissionSet) Add(newPerm string) bool
- func (ps *PermissionSet) All() []string
- func (ps *PermissionSet) Contain(needle string) bool
- func (ps *PermissionSet) MarshalJSON() ([]byte, error)
- func (ps *PermissionSet) OverwriteWith(newPS *PermissionSet) *PermissionSet
- func (ps *PermissionSet) Size() int
- func (ps *PermissionSet) UnmarshalJSON(b []byte) error
- type Request
- type Response
- type SubscriptionEntry
Constants ¶
const ( OPTIONS string = "OPTIONS" AUTH = "AUTH" GET = "GET" LIST = "LIST" CREATE = "CREATE" PATCH = "PATCH" DELETE = "DELETE" READ = "READ" WRITE = "WRITE" SUCCEEDED = "SUCCEEDED" FAILED = "FAILED" CREATED = "CREATED" UPDATED = "UPDATED" DELETED = "DELETED" )
const ( PermissionRead string = "read" PermissionNotRead = "not-read" PermissionWrite = "write" PermissionNotWrite = "not-write" PermissionDelete = "delete" PermissionNotDelete = "not-delete" )
const ( StatusOK uint = 200 StatusCreated = 201 StatusNoContent = 204 StatusMovedPermanently = 301 StatusNotModified = 304 StatusAdditionalDataNeeded = 310 StatusBadRequest = 400 StatusForbidden = 403 StatusNotFound = 404 StatusMethodNotAllowed = 405 StatusConflict = 409 StatusPreconditionFailed = 412 StatusRequestEntityTooLarge = 413 StatusInternalServerError = 500 StatusNotImplemented = 501 StatusBadGateway = 502 StatusGatewayTimeout = 504 )
Variables ¶
This section is empty.
Functions ¶
func IsPermission ¶
func NegatePermission ¶
Types ¶
type AccessControlEntry ¶
type AccessControlEntry struct { Data *PermissionSet `json:"data,omitempty"` Acl *PermissionSet `json:"acl,omitempty"` Subscriptions *PermissionSet `json:"subscriptions,omitempty"` Children *PermissionSet `json:"children,omitempty"` }
func NewAccessControlEntry ¶
func NewAccessControlEntry() *AccessControlEntry
func (*AccessControlEntry) OverwriteWith ¶
func (ace *AccessControlEntry) OverwriteWith(newACE *AccessControlEntry) *AccessControlEntry
func (*AccessControlEntry) Patch ¶
func (ace *AccessControlEntry) Patch(patch PatchObject) error
type AccessControlList ¶
type AccessControlList struct { Owner *AccessControlEntry `json:"owner,omitempty"` Users map[string]*AccessControlEntry `json:"users,omitempty"` Groups map[string]*AccessControlEntry `json:"groups,omitempty"` Others *AccessControlEntry `json:"others,omitempty"` }
AccessControlList represents the acl content of an Object.
func NewAccessControlList ¶
func NewAccessControlList() *AccessControlList
NewAccessControlList creates a new AccessControlList and initializes fields to non-nil values.
func (*AccessControlList) OverwriteWith ¶
func (acl *AccessControlList) OverwriteWith(newACL *AccessControlList) *AccessControlList
func (*AccessControlList) Patch ¶
func (acl *AccessControlList) Patch(patch PatchObject) error
type Attachment ¶
type Attachment struct { Name string `json:"name,omitempty"` Size uint `json:"size,omitempty"` Type string `json:"type,omitempty"` }
Attachment represents a the content of the attachemnt field in an object.
func NewAttachment ¶
func NewAttachment() *Attachment
NewAttachment creates a new Attachment struct and returns it.
func (*Attachment) Patch ¶
func (a *Attachment) Patch(patch PatchObject) error
type Message ¶
type Message interface { String() string // contains filtered or unexported methods }
Message is the common interface of all FOSP messag objects.
type Notification ¶
Notification is an object that represents a FOSP notification message.
func NewNotification ¶
func NewNotification(event string, url *url.URL) *Notification
NewNotification creates a new Notification.
func (*Notification) String ¶
func (n *Notification) String() string
type Object ¶
type Object struct { Parent *Object `json:"-"` URL *url.URL `json:"-"` Btime time.Time `json:"btime,omitempty"` Mtime time.Time `json:"mtime,omitempty"` Owner string `json:"owner,omitempty"` Acl *AccessControlList `json:"acl,omitempty"` Subscriptions map[string]*SubscriptionEntry `json:"subscriptions,omitempty"` Attachment *Attachment `json:"attachment,omitempty"` Type interface{} `json:"type,omitempty"` Data interface{} `json:"data,omitempty"` }
Object represents a FOSP object.
func (*Object) Patch ¶
func (o *Object) Patch(patch PatchObject) error
func (*Object) PermissionsForAcl ¶
func (o *Object) PermissionsForAcl(user string, groups ...string) *PermissionSet
func (*Object) PermissionsForChildren ¶
func (o *Object) PermissionsForChildren(user string, groups ...string) *PermissionSet
func (*Object) PermissionsForData ¶
func (o *Object) PermissionsForData(user string, groups ...string) *PermissionSet
func (*Object) PermissionsForSubscriptions ¶
func (o *Object) PermissionsForSubscriptions(user string, groups ...string) *PermissionSet
func (*Object) ReducedACL ¶
func (o *Object) ReducedACL() *AccessControlList
type PatchObject ¶
type PatchObject map[string]interface{}
func (PatchObject) GetStringSlice ¶
func (p PatchObject) GetStringSlice(field string) ([]string, bool, error)
func (PatchObject) PatchString ¶
func (p PatchObject) PatchString(target *string, field string) error
func (PatchObject) PatchStruct ¶
func (p PatchObject) PatchStruct(target interface{}, field string) error
type Patchable ¶
type Patchable interface {
Patch(PatchObject) error
}
type PermissionSet ¶
type PermissionSet struct {
// contains filtered or unexported fields
}
func NewPermissionSet ¶
func NewPermissionSet(permissions ...string) *PermissionSet
func (*PermissionSet) Add ¶
func (ps *PermissionSet) Add(newPerm string) bool
func (*PermissionSet) All ¶
func (ps *PermissionSet) All() []string
func (*PermissionSet) Contain ¶
func (ps *PermissionSet) Contain(needle string) bool
func (*PermissionSet) MarshalJSON ¶
func (ps *PermissionSet) MarshalJSON() ([]byte, error)
func (*PermissionSet) OverwriteWith ¶
func (ps *PermissionSet) OverwriteWith(newPS *PermissionSet) *PermissionSet
func (*PermissionSet) Size ¶
func (ps *PermissionSet) Size() int
func (*PermissionSet) UnmarshalJSON ¶
func (ps *PermissionSet) UnmarshalJSON(b []byte) error
type Request ¶
Request represents a FOSP request message.
func NewRequest ¶
NewRequest creates a new request.
type Response ¶
Response represents a FOSP response message.
func NewResponse ¶
NewResponse creates a new response message.
type SubscriptionEntry ¶
type SubscriptionEntry struct { Depth int `json:"depth,omitempty"` Events []string `json:"events,omitempty"` }
SubscriptionEntry represents an entry in the subscriptions list of an object.
func NewSubscriptionEntry ¶
func NewSubscriptionEntry() *SubscriptionEntry
func (*SubscriptionEntry) Patch ¶
func (sub *SubscriptionEntry) Patch(patch PatchObject)