rest

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2018 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Overview

Package rest exposes a REST API to manage shared rooms.

Package rest implements all the share logic for Cells and Links.

It is a high-level service using many other services for crud-ing shares through the REST API.

Index

Constants

View Source
const PasswordComplexitySuffix = "#$!Az1"

Variables

This section is empty.

Functions

func DeleteHashDocument

func DeleteHashDocument(ctx context.Context, shareId string) error

func LoadHashDocumentData

func LoadHashDocumentData(ctx context.Context, shareLink *rest.ShareLink, acls []*idm.ACL) error

func StoreHashDocument

func StoreHashDocument(ctx context.Context, link *rest.ShareLink, updateHash ...string) error

Types

type SharesHandler

type SharesHandler struct {
	resources.ResourceProviderHandler
}

SharesHandler implements handler methods for the share REST service.

func NewSharesHandler

func NewSharesHandler() *SharesHandler

NewSharesHandler simply creates a new SharesHandler.

func (*SharesHandler) AclsToCellAcls

func (h *SharesHandler) AclsToCellAcls(ctx context.Context, acls []*idm.ACL) map[string]*rest.CellAcl

AclsToCellAcls Rewrites a flat list of ACLs to a structured map of CellAcls (more easily usable by clients).

func (*SharesHandler) CheckLinkRootNodes added in v1.2.0

func (h *SharesHandler) CheckLinkRootNodes(ctx context.Context, link *rest.ShareLink) error

CheckLinkRootNodes loads the root nodes and check if one of the is readonly. If so, check that link permissions do not try to set the Upload mode.

func (*SharesHandler) CommonAclsForWorkspace

func (h *SharesHandler) CommonAclsForWorkspace(ctx context.Context, workspaceId string) (result []*idm.ACL, detectedRoots []string, err error)

CommonAclsForWorkspace makes successive calls to ACL service to get all ACLs for a given workspace.

func (*SharesHandler) ComputeTargetAcls added in v1.2.0

func (h *SharesHandler) ComputeTargetAcls(ctx context.Context, shareRequest *rest.PutCellRequest, workspaceId string, readonly bool) []*idm.ACL

ComputeTargetAcls create ACL objects that should be applied for this cell.

func (*SharesHandler) DeleteCell

func (h *SharesHandler) DeleteCell(req *restful.Request, rsp *restful.Response)

DeleteCell loads the workspace and its root nodes and eventually removes room root totally.

func (*SharesHandler) DeleteRootNodeRecursively

func (h *SharesHandler) DeleteRootNodeRecursively(ctx context.Context, roomNode *tree.Node) error

DeleteRootNodeRecursively loads all children of a root node and delete them, including the .pydio hidden files when they are folders.

func (h *SharesHandler) DeleteShareLink(req *restful.Request, rsp *restful.Response)

DeleteShareLink deletes a link information.

func (*SharesHandler) DeleteWorkspace

func (h *SharesHandler) DeleteWorkspace(ctx context.Context, scope idm.WorkspaceScope, workspaceId string) error

DeleteWorkspace deletes a workspace and associated policies and ACLs. It also deletes the room node if necessary.

func (*SharesHandler) DiffAcls

func (h *SharesHandler) DiffAcls(ctx context.Context, initial []*idm.ACL, newOnes []*idm.ACL) (add []*idm.ACL, remove []*idm.ACL)

DiffAcls compares to slices of ACLs on their RoleID and Action and returns slices of Acls to add and to remove.

func (*SharesHandler) DiffReadRoles

func (h *SharesHandler) DiffReadRoles(ctx context.Context, initial []*idm.ACL, newOnes []*idm.ACL) (add []string, remove []string)

DiffReadRoles detects the roles that have been globally added or removed, whatever the node.

func (*SharesHandler) Filter

func (h *SharesHandler) Filter() func(string) string

Filter returns a function to filter the swagger path.

func (*SharesHandler) GetCell

func (h *SharesHandler) GetCell(req *restful.Request, rsp *restful.Response)

GetCell simply retrieves a shared room from its UUID.

func (*SharesHandler) GetOrCreateHiddenUser

func (h *SharesHandler) GetOrCreateHiddenUser(ctx context.Context, link *rest.ShareLink, passwordEnabled bool, updatePassword string) (user *idm.User, err error)

GetOrCreateHiddenUser will load or create a user to create a ShareLink with.

func (*SharesHandler) GetOrCreateWorkspace

func (h *SharesHandler) GetOrCreateWorkspace(ctx context.Context, wsUuid string, scope idm.WorkspaceScope, label string, description string, updateIfNeeded bool) (*idm.Workspace, bool, error)

GetOrCreateWorkspace finds a workspace by its Uuid or creates it with the current user ResourcePolicies if it does not already exist.

func (h *SharesHandler) GetShareLink(req *restful.Request, rsp *restful.Response)

GetShareLink loads link information.

func (*SharesHandler) GetTemplateACLsForMinisite

func (h *SharesHandler) GetTemplateACLsForMinisite(ctx context.Context, roleId string, permissions []rest.ShareLinkAccessType, aclClient idm.ACLServiceClient) (acls []*idm.ACL, err error)

GetTemplateACLsForMinisite loads actions and parameter acls from specific template roles.

func (*SharesHandler) ListSharedResources

func (h *SharesHandler) ListSharedResources(req *restful.Request, rsp *restful.Response)

ListSharedResources implements the corresponding Rest API operation

func (*SharesHandler) LoadAdminRootNodes added in v1.0.1

func (h *SharesHandler) LoadAdminRootNodes(ctx context.Context, detectedRoots []string) (rootNodes map[string]*tree.Node)

LoadDetectedRootNodes find actual nodes in the tree, and enrich their metadata if they appear in many workspaces for the current user.

func (*SharesHandler) LoadCellAclsObjects

func (h *SharesHandler) LoadCellAclsObjects(ctx context.Context, roomAcls map[string]*rest.CellAcl) error

LoadCellAclsObjects loads associated users / groups / roles based on the role Ids of the acls.

func (*SharesHandler) LoadDetectedRootNodes

func (h *SharesHandler) LoadDetectedRootNodes(ctx context.Context, detectedRoots []string) (rootNodes map[string]*tree.Node)

LoadDetectedRootNodes find actual nodes in the tree, and enrich their metadata if they appear in many workspaces for the current user.

func (*SharesHandler) OwnerResourcePolicies

func (h *SharesHandler) OwnerResourcePolicies(ctx context.Context, resourceId string) []*service2.ResourcePolicy

OwnerResourcePolicies produces a set of policies given ownership to current context user, read/write to current context user, and write access to profile:admin (can be useful for admin).

func (*SharesHandler) ParseRootNodes

func (h *SharesHandler) ParseRootNodes(ctx context.Context, shareRequest *rest.PutCellRequest) (error, *tree.Node, bool)

ParseRootNodes reads the request property to either create a new node using the "rooms" Virtual node, or just verify that the root nodes are not empty.

func (*SharesHandler) PutCell

func (h *SharesHandler) PutCell(req *restful.Request, rsp *restful.Response)

PutCell creates or updates a shared room (a.k.a a Cell) via REST API.

func (h *SharesHandler) PutShareLink(req *restful.Request, rsp *restful.Response)

PutShareLink creates or updates a link to a shared item.

func (*SharesHandler) SwaggerTags

func (h *SharesHandler) SwaggerTags() []string

SwaggerTags list the names of the service tags declared in the swagger json implemented by this service.

func (*SharesHandler) UpdateACLsForHiddenUser

func (h *SharesHandler) UpdateACLsForHiddenUser(ctx context.Context, roleId string, workspaceId string, rootNodes []*tree.Node, permissions []rest.ShareLinkAccessType, update bool) error

UpdateACLsForHiddenUser deletes and replaces access ACLs for a hidden user.

func (*SharesHandler) UpdatePoliciesFromAcls

func (h *SharesHandler) UpdatePoliciesFromAcls(ctx context.Context, workspace *idm.Workspace, initial []*idm.ACL, target []*idm.ACL) bool

UpdatePoliciesFromAcls recomputes the required policies from acl changes.

func (*SharesHandler) WorkspaceToCellObject

func (h *SharesHandler) WorkspaceToCellObject(ctx context.Context, workspace *idm.Workspace) (*rest.Cell, error)

WorkspaceToCellObject rewrites a workspace to a Cell object by reloading its ACLs.

func (*SharesHandler) WorkspaceToShareLinkObject

func (h *SharesHandler) WorkspaceToShareLinkObject(ctx context.Context, workspace *idm.Workspace) (*rest.ShareLink, error)

Jump to

Keyboard shortcuts

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