fosp

package
v0.0.0-...-bb09860 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2015 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package fosp provides primitives for FOSP client and server implementations.

Code example:

srv := NewServer(dbDriver, domain)

Index

Constants

View Source
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"
)
View Source
const (
	PermissionRead      string = "read"
	PermissionNotRead          = "not-read"
	PermissionWrite            = "write"
	PermissionNotWrite         = "not-write"
	PermissionDelete           = "delete"
	PermissionNotDelete        = "not-delete"
)
View Source
const (
	StatusOK        uint = 200
	StatusCreated        = 201
	StatusNoContent      = 204

	StatusMovedPermanently     = 301
	StatusNotModified          = 304
	StatusAdditionalDataNeeded = 310

	StatusBadRequest            = 400
	StatusUnauthorized          = 401
	StatusForbidden             = 403
	StatusNotFound              = 404
	StatusMethodNotAllowed      = 405
	StatusConflict              = 409
	StatusPreconditionFailed    = 412
	StatusRequestEntityTooLarge = 413

	StatusInternalServerError = 500
	StatusNotImplemented      = 501
	StatusBadGateway          = 502
	StatusServiceUnavailable  = 503
	StatusGatewayTimeout      = 504
)

Variables

This section is empty.

Functions

func IsPermission

func IsPermission(perm string) bool

func NegatePermission

func NegatePermission(perm string) string

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

type Notification struct {
	Event  string
	Header textproto.MIMEHeader
	Body   io.Reader

	URL *url.URL
}

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 NewObject

func NewObject() *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

type Request struct {
	Method string
	Header textproto.MIMEHeader
	Body   io.Reader

	URL *url.URL
}

Request represents a FOSP request message.

func NewRequest

func NewRequest(method string, url *url.URL) *Request

NewRequest creates a new request.

func (*Request) String

func (r *Request) String() string

type Response

type Response struct {
	Status string
	Header textproto.MIMEHeader
	Body   io.Reader

	Code uint
}

Response represents a FOSP response message.

func NewResponse

func NewResponse(status string, code uint) *Response

NewResponse creates a new response message.

func (*Response) String

func (r *Response) String() string

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)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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