Help us shape the future of Go! Take the 2026 Go Developer Survey

share

package
v2.52.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// NoState can be used to signal the filter matching functions to ignore the share state.
	NoState collaboration.ShareState = -1
)

Variables

This section is empty.

Functions

func FilterFiltersByType

func FilterFiltersByType(f []*collaboration.Filter, t collaboration.Filter_Type) []*collaboration.Filter

FilterFiltersByType returns a slice of filters by a given type. If no filter with the given type exists within the filters, then an empty slice is returned.

func GroupFiltersByType

func GroupFiltersByType(filters []*collaboration.Filter) map[collaboration.Filter_Type][]*collaboration.Filter

GroupFiltersByType groups the given filters and returns a map using the filter type as the key.

func GroupGranteeFilter

func GroupGranteeFilter() *collaboration.Filter

GroupGranteeFilter is an abstraction for creating filter by grantee type group.

func IsCreatedByUser

func IsCreatedByUser(share *collaboration.Share, user *userv1beta1.User) bool

IsCreatedByUser checks if the user is the owner or creator of the share.

func IsExpired

func IsExpired(s *collaboration.Share) bool

IsExpired tests whether a share is expired

func IsGrantedToUser

func IsGrantedToUser(share *collaboration.Share, user *userv1beta1.User) bool

IsGrantedToUser checks if the user is a grantee of the share. Either by a user grant or by a group grant.

func MatchesAnyFilter

func MatchesAnyFilter(share *collaboration.Share, state collaboration.ShareState, filters []*collaboration.Filter) bool

MatchesAnyFilter checks if the share passes at least one of the given filters.

func MatchesFilter

func MatchesFilter(share *collaboration.Share, state collaboration.ShareState, filter *collaboration.Filter) bool

MatchesFilter tests if the share passes the filter.

func MatchesFilters

func MatchesFilters(share *collaboration.Share, filters []*collaboration.Filter) bool

MatchesFilters checks if the share passes the given filters. Filters of the same type form a disjuntion, a logical OR. Filters of separate type form a conjunction, a logical AND. Here is an example: (resource_id=1 OR resource_id=2) AND (grantee_type=USER OR grantee_type=GROUP)

func MatchesFiltersWithState

func MatchesFiltersWithState(share *collaboration.Share, state collaboration.ShareState, filters []*collaboration.Filter) bool

MatchesFiltersWithState checks if the share passes the given filters. This can check filter by share state Filters of the same type form a disjuntion, a logical OR. Filters of separate type form a conjunction, a logical AND. Here is an example: (resource_id=1 OR resource_id=2) AND (grantee_type=USER OR grantee_type=GROUP)

func ResourceIDFilter

func ResourceIDFilter(id *provider.ResourceId) *collaboration.Filter

ResourceIDFilter is an abstraction for creating filter by resource id.

func SpaceIDFilter

func SpaceIDFilter(id string) *collaboration.Filter

SpaceIDFilter is an abstraction for creating filter by space id.

func SpaceRootFilter added in v2.45.0

func SpaceRootFilter(spaceRoot bool) *collaboration.Filter

SpaceRootFilter is an abstraction for filtering shares by whether the shared resource is a space root. Pass true to include only space-root shares (space membership), false to exclude them (file/folder shares only).

func StateFilter

func StateFilter(state collaboration.ShareState) *collaboration.Filter

StateFilter is an abstraction for creating filter by share state.

func UserGranteeFilter

func UserGranteeFilter() *collaboration.Filter

UserGranteeFilter is an abstraction for creating filter by grantee type user.

Types

type DumpableManager

type DumpableManager interface {
	Dump(ctx context.Context, shareChan chan<- *collaboration.Share, receivedShareChan chan<- ReceivedShareWithUser) error
}

DumpableManager defines a share manager which supports dumping its contents

type LoadableManager

type LoadableManager interface {
	Load(ctx context.Context, shareChan <-chan *collaboration.Share, receivedShareChan <-chan ReceivedShareWithUser) error
}

LoadableManager defines a share manager which supports loading contents from a dump

type Manager

type Manager interface {
	// Create a new share in fn with the given acl.
	Share(ctx context.Context, md *provider.ResourceInfo, g *collaboration.ShareGrant) (*collaboration.Share, error)

	// GetShare gets the information for a share by the given ref.
	GetShare(ctx context.Context, ref *collaboration.ShareReference) (*collaboration.Share, error)

	// Unshare deletes the share pointed by ref.
	Unshare(ctx context.Context, ref *collaboration.ShareReference) error

	// UpdateShare updates the mode of the given share.
	UpdateShare(ctx context.Context, ref *collaboration.ShareReference, p *collaboration.SharePermissions, updated *collaboration.Share, fieldMask *field_mask.FieldMask) (*collaboration.Share, error)

	// ListShares returns the shares created by the user. If md is provided is not nil,
	// it returns only shares attached to the given resource.
	ListShares(ctx context.Context, filters []*collaboration.Filter) ([]*collaboration.Share, error)

	// ListReceivedShares returns the list of shares the user has access to. `forUser` parameter for service accounts only
	ListReceivedShares(ctx context.Context, filters []*collaboration.Filter, forUser *userv1beta1.UserId) ([]*collaboration.ReceivedShare, error)

	// GetReceivedShare returns the information for a received share.
	GetReceivedShare(ctx context.Context, ref *collaboration.ShareReference) (*collaboration.ReceivedShare, error)

	// UpdateReceivedShare updates the received share with share state.`forUser` parameter for service accounts only
	UpdateReceivedShare(ctx context.Context, share *collaboration.ReceivedShare, fieldMask *field_mask.FieldMask, forUser *userv1beta1.UserId) (*collaboration.ReceivedShare, error)
}

Manager is the interface that manipulates shares.

type Metadata

type Metadata struct {
	ETag  string
	Mtime *types.Timestamp
}

Metadata contains Metadata for a share

type ReceivedShareWithUser

type ReceivedShareWithUser struct {
	UserID        *userv1beta1.UserId
	ReceivedShare *collaboration.ReceivedShare
}

ReceivedShareWithUser holds the relevant information for representing a received share of a user

Jump to

Keyboard shortcuts

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