Documentation ¶
Overview ¶
Package conversions sits between CS3 type definitions and OCS API Responses
Index ¶
- Constants
- Variables
- func AsCS3Permissions(p int, rp *provider.ResourcePermissions) *provider.ResourcePermissions
- func GetPublicShareManager(manager string, m map[string]map[string]interface{}) (publicshare.Manager, error)
- func GetUserManager(manager string, m map[string]map[string]interface{}) (user.Manager, error)
- func LocalUserIDToString(userID *userpb.UserId) string
- func Permissions2Role(p Permissions) string
- func Role2CS3Permissions(r string) (*provider.ResourcePermissions, error)
- func UserIDToString(userID *userpb.UserId) string
- type ExactMatchesData
- type MatchData
- type MatchValueData
- type Permissions
- type ResourceType
- type ShareData
- type ShareType
- type ShareeData
Constants ¶
const ( // RoleLegacy provides backwards compatibility RoleLegacy string = "legacy" // RoleViewer grants non-editor role on a resource RoleViewer string = "viewer" // RoleEditor grants editor permission on a resource RoleEditor string = "editor" // RoleCoowner grants owner permissions on a resource RoleCoowner string = "coowner" )
Variables ¶
var ( // ErrPermissionNotInRange defines a permission specific error. ErrPermissionNotInRange = fmt.Errorf("The provided permission is not between %d and %d", PermissionInvalid, PermissionAll) )
Functions ¶
func AsCS3Permissions ¶ added in v0.1.0
func AsCS3Permissions(p int, rp *provider.ResourcePermissions) *provider.ResourcePermissions
AsCS3Permissions returns permission values as cs3api permissions TODO sort out mapping, this is just a first guess TODO use roles to make this configurable
func GetPublicShareManager ¶
func GetPublicShareManager(manager string, m map[string]map[string]interface{}) (publicshare.Manager, error)
GetPublicShareManager returns a connection to a public share manager
func GetUserManager ¶
GetUserManager returns a connection to a user share manager
func LocalUserIDToString ¶
LocalUserIDToString transforms a cs3api user id into an ocs data model without domain name
func Permissions2Role ¶ added in v0.1.0
func Permissions2Role(p Permissions) string
Permissions2Role performs permission conversions for user and federated shares
func Role2CS3Permissions ¶ added in v0.1.0
func Role2CS3Permissions(r string) (*provider.ResourcePermissions, error)
Role2CS3Permissions converts string roles (from the request body) into cs3 permissions TODO(refs) consider using a mask instead of booleans here, might reduce all this boilerplate
func UserIDToString ¶ added in v0.1.0
UserIDToString transforms a cs3api user id into an ocs data model
Types ¶
type ExactMatchesData ¶
type ExactMatchesData struct { Users []*MatchData `json:"users" xml:"users"` Groups []*MatchData `json:"groups" xml:"groups"` Remotes []*MatchData `json:"remotes" xml:"remotes"` }
ExactMatchesData hold exact matches
type MatchData ¶
type MatchData struct { Label string `json:"label" xml:"label"` Value *MatchValueData `json:"value" xml:"value"` }
MatchData describes a single match
type Permissions ¶
type Permissions uint
Permissions reflects the CRUD permissions used in the OCS sharing API
const ( // PermissionInvalid grants no permissions on a resource PermissionInvalid Permissions = 0 // PermissionRead grants read permissions on a resource PermissionRead Permissions = 1 << (iota - 1) // PermissionWrite grants write permissions on a resource PermissionWrite // PermissionCreate grants create permissions on a resource PermissionCreate // PermissionDelete grants delete permissions on a resource PermissionDelete PermissionShare // PermissionAll grants all permissions on a resource PermissionAll Permissions = (1 << (iota - 1)) - 1 )
func NewPermissions ¶
func NewPermissions(val int) (Permissions, error)
NewPermissions creates a new Permissions instance. The value must be in the valid range.
func Permissions2OCSPermissions ¶ added in v1.1.0
func Permissions2OCSPermissions(p *provider.ResourcePermissions) Permissions
TODO sort out mapping, this is just a first guess public link permissions to OCS permissions
func UserSharePermissions2OCSPermissions ¶ added in v0.1.0
func UserSharePermissions2OCSPermissions(sp *collaboration.SharePermissions) Permissions
UserSharePermissions2OCSPermissions transforms cs3api permissions into OCS Permissions data model
func (Permissions) Contain ¶
func (p Permissions) Contain(other Permissions) bool
Contain tests if the permissions contain another one.
type ResourceType ¶
type ResourceType int
ResourceType indicates the OCS type of the resource
func (ResourceType) String ¶
func (rt ResourceType) String() (s string)
type ShareData ¶
type ShareData struct { string `json:"id" xml:"id"` ShareType ShareType `json:"share_type" xml:"share_type"` UIDOwner string `json:"uid_owner" xml:"uid_owner"` DisplaynameOwner string `json:"displayname_owner" xml:"displayname_owner"` // TODO(jfd) change the default to read only Permissions Permissions `json:"permissions" xml:"permissions"` STime uint64 `json:"stime" xml:"stime"` Parent string `json:"parent" xml:"parent"` Expiration string `json:"expiration" xml:"expiration"` Token string `json:"token" xml:"token"` UIDFileOwner string `json:"uid_file_owner" xml:"uid_file_owner"` DisplaynameFileOwner string `json:"displayname_file_owner" xml:"displayname_file_owner"` AdditionalInfoOwner string `json:"additional_info_owner" xml:"additional_info_owner"` AdditionalInfoFileOwner string `json:"additional_info_file_owner" xml:"additional_info_file_owner"` State int `json:"state" xml:"state"` Path string `json:"path" xml:"path"` ItemType string `json:"item_type" xml:"item_type"` // The RFC2045-compliant mimetype of the file. ItemSource string `json:"item_source" xml:"item_source"` FileSource string `json:"file_source" xml:"file_source"` FileParent string `json:"file_parent" xml:"file_parent"` FileTarget string `json:"file_target" xml:"file_target"` // - a GID (group id) if it is being shared with a group or // - a UID (user id) if the share is shared with a user. ShareWith string `json:"share_with,omitempty" xml:"share_with,omitempty"` ShareWithDisplayname string `json:"share_with_displayname,omitempty" xml:"share_with_displayname,omitempty"` ShareWithAdditionalInfo string `json:"share_with_additional_info" xml:"share_with_additional_info"` MailSend int `json:"mail_send" xml:"mail_send"` Name string `json:"name" xml:"name"` URL string `json:"url,omitempty" xml:"url,omitempty"` Attributes string `json:"attributes,omitempty" xml:"attributes,omitempty"` }ID
ShareData represents https://doc.owncloud.com/server/developer_manual/core/ocs-share-api.html#response-attributes-1
func PublicShare2ShareData ¶
PublicShare2ShareData converts a cs3api public share into shareData data model