rest

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2018 License: AGPL-3.0 Imports: 29 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 HashDocument

type HashDocument struct {
	ShareType             string                      `json:"SHARE_TYPE"`
	ExpireTime            int64                       `json:"EXPIRE_TIME"`
	ShortFormUrl          string                      `json:"SHORT_FORM_URL"`
	RepositoryId          string                      `json:"REPOSITORY"`
	ParentRepositoryId    string                      `json:"PARENT_REPOSITORY_ID"`
	DownloadDisabled      bool                        `json:"DOWNLOAD_DISABLED"`
	ApplicationBase       string                      `json:"PYDIO_APPLICATION_BASE"`
	TemplateName          string                      `json:"PYDIO_TEMPLATE_NAME"`
	DownloadLimit         int64                       `json:"DOWNLOAD_LIMIT"`
	DownloadCount         int64                       `json:"DOWNLOAD_COUNT"`
	PreLogUser            string                      `json:"PRELOG_USER"`
	PresetLogin           string                      `json:"PRESET_LOGIN"`
	Target                string                      `json:"TARGET"`
	TargetUsers           map[string]*TargetUserEntry `json:"TARGET_USERS"`
	RestrictToTargetUsers bool                        `json:"RESTRICT_TO_TARGET_USERS"`
	OwnerId               string                      `json:"OWNER_ID"`
	PreUserUuid           string                      `json:"USER_UUID"`
}

HashDocument is a Json Marshallable representation of a document, compatible with legacy.

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) 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) 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) 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

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)

type TargetUserEntry

type TargetUserEntry struct {
	Display       string `json:"display"`
	DownloadCount int32  `json:"download_count"`
}

Jump to

Keyboard shortcuts

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