utils

package
v1.29.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: Apache-2.0 Imports: 20 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToCS3PublicShare

func ConvertToCS3PublicShare(s DBShare) *link.PublicShare

ConvertToCS3PublicShare converts a DBShare to a CS3API public share. Here we take the shortcut that the Owner's and Creator's user type is PRIMARY.

func ConvertToCS3ReceivedShare

func ConvertToCS3ReceivedShare(s DBShare, gtype userpb.UserType) *collaboration.ReceivedShare

ConvertToCS3ReceivedShare converts a DBShare and a grantee userType to a CS3API collaboration received share.

func ConvertToCS3Share

func ConvertToCS3Share(s DBShare, gtype userpb.UserType) *collaboration.Share

ConvertToCS3Share converts a DBShare and a grantee userType to a CS3API collaboration share. Here we take the shortcut that the Owner's and Creator's user type is PRIMARY.

func ExtractGrantee

func ExtractGrantee(t int, g string, gtype userpb.UserType) *provider.Grantee

ExtractGrantee retrieves the CS3API Grantee from a grantee type and username/groupname. The grantee userType is relevant only for users.

func FormatGrantee

func FormatGrantee(g *provider.Grantee) (int, string)

FormatGrantee formats a CS3API grantee to a (int, string) tuple.

func FormatGroupID

func FormatGroupID(u *grouppb.GroupId) string

FormatGroupID formats a CS3API group ID to a string.

func FormatUserID

func FormatUserID(u *userpb.UserId) string

FormatUserID formats a CS3API user ID as a string.

func IntToShareState

func IntToShareState(g int) collaboration.ShareState

IntToShareState retrieves the received share state from an integer.

func IntTosharePerm

func IntTosharePerm(p int, itemType string) *provider.ResourcePermissions

IntTosharePerm retrieves read/write permissions from an integer.

func MakeUserID added in v1.29.0

func MakeUserID(u string) *userpb.UserId

MakeUserID generates a CS3API user ID from a username, ASSUMING user type is primary.

func ResourceTypeToItem

func ResourceTypeToItem(r provider.ResourceType) string

ResourceTypeToItem maps a resource type to a string.

func ResourceTypeToItemInt

func ResourceTypeToItemInt(r provider.ResourceType) int

ResourceTypeToItemInt maps a resource type to an integer.

func SharePermToInt

func SharePermToInt(p *provider.ResourcePermissions) int

SharePermToInt maps read/write permissions to an integer.

Types

type APITokenManager

type APITokenManager struct {
	// contains filtered or unexported fields
}

APITokenManager stores config related to api management.

func InitAPITokenManager

func InitAPITokenManager(conf map[string]interface{}) (*APITokenManager, error)

InitAPITokenManager initializes a new APITokenManager.

func (*APITokenManager) SendAPIGetRequest

func (a *APITokenManager) SendAPIGetRequest(ctx context.Context, url string, forceRenewal bool, v any) error

SendAPIGetRequest makes an API GET Request to the passed URL.

type DBShare

type DBShare struct {
	ID                           string
	UIDOwner                     string
	UIDInitiator                 string
	Prefix                       string
	ItemSource                   string
	ItemType                     string
	ShareWith                    string
	Token                        string
	Expiration                   string
	Permissions                  int
	ShareType                    int
	ShareName                    string
	STime                        int
	FileTarget                   string
	State                        int
	Quicklink                    bool
	Description                  string
	NotifyUploads                bool
	NotifyUploadsExtraRecipients sql.NullString
}

DBShare stores information about user and public shares.

type OIDCToken

type OIDCToken struct {
	sync.Mutex // concurrent access to apiToken and tokenExpirationTime
	// contains filtered or unexported fields
}

OIDCToken stores the OIDC token used to authenticate requests to the REST API service.

Jump to

Keyboard shortcuts

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