ocmd

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: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidParameters = errors.New("invalid parameters")

ErrInvalidParameters is the error returned by the shares endpoint when the request does not contain required properties.

View Source
var ErrServiceNotTrusted = errors.New("service is not trusted to accept invitations")

ErrServiceNotTrusted is the error returned by the invite-accepted endpoint when the service is not trusted to accept invitations.

View Source
var ErrTokenInvalid = errors.New("the invitation token is invalid or not found")

ErrTokenInvalid is the error returned by the invite-accepted endpoint when the token is not valid or not existing.

View Source
var ErrUserAlreadyAccepted = errors.New("invitation already accepted")

ErrUserAlreadyAccepted is the error returned by the invite-accepted endpoint when a token was already used by a user in the remote cloud.

Functions

func GetProtocolName

func GetProtocolName(p Protocol) string

GetProtocolName returns the name of the protocol by reflection.

func New

func New(ctx context.Context, m map[string]interface{}) (global.Service, error)

New returns a new ocmd object, that implements the OCM APIs specified in https://cs3org.github.io/OCM-API/docs.html

Types

type Datatx

type Datatx struct {
	SharedSecret string `json:"sharedSecret" validate:"required"`
	SourceURI    string `json:"srcUri"       validate:"required"`
	Size         uint64 `json:"size"         validate:"required"`
}

Datatx contains the parameters for the Datatx protocol.

func (*Datatx) ToOCMProtocol

func (w *Datatx) ToOCMProtocol() *ocm.Protocol

ToOCMProtocol convert the protocol to a ocm Protocol struct.

type InviteAcceptedRequest

type InviteAcceptedRequest struct {
	UserID            string `json:"userID"`
	Email             string `json:"email"`
	Name              string `json:"name"`
	RecipientProvider string `json:"recipientProvider"`
	Token             string `json:"token"`
}

InviteAcceptedRequest contains the parameters for accepting an invitation.

type NewShareRequest

type NewShareRequest struct {
	ShareWith         string    `json:"shareWith"`
	Name              string    `json:"name"`
	Description       string    `json:"description"`
	ProviderID        string    `json:"providerId"`
	Owner             string    `json:"owner"`
	Sender            string    `json:"sender"`
	OwnerDisplayName  string    `json:"ownerDisplayName"`
	SenderDisplayName string    `json:"senderDisplayName"`
	ShareType         string    `json:"shareType"`
	Expiration        uint64    `json:"expiration"`
	ResourceType      string    `json:"resourceType"`
	Protocols         Protocols `json:"protocol"`
}

NewShareRequest contains the parameters for creating a new OCM share.

type NewShareResponse

type NewShareResponse struct {
	RecipientDisplayName string `json:"recipientDisplayName"`
}

NewShareResponse is the response returned when creating a new share.

type OCMClient

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

OCMClient is the client for an OCM provider.

func NewClient

func NewClient(timeout time.Duration, insecure bool) *OCMClient

NewClient returns a new OCMClient.

func (*OCMClient) Discover

func (c *OCMClient) Discover(ctx context.Context, endpoint string) (*wellknown.OcmDiscoveryData, error)

Discover returns a number of properties used to discover the capabilities offered by a remote cloud storage. https://cs3org.github.io/OCM-API/docs.html?branch=develop&repo=OCM-API&user=cs3org#/paths/~1ocm-provider/get

func (*OCMClient) InviteAccepted

func (c *OCMClient) InviteAccepted(ctx context.Context, endpoint string, r *InviteAcceptedRequest) (*User, error)

InviteAccepted informs the sender that the invitation was accepted to start sharing https://cs3org.github.io/OCM-API/docs.html?branch=develop&repo=OCM-API&user=cs3org#/paths/~1invite-accepted/post

func (*OCMClient) NewShare

func (c *OCMClient) NewShare(ctx context.Context, endpoint string, r *NewShareRequest) (*NewShareResponse, error)

NewShare creates a new share. https://github.com/cs3org/OCM-API/blob/develop/spec.yaml

type Protocol

type Protocol interface {
	// ToOCMProtocol convert the protocol to a ocm Protocol struct
	ToOCMProtocol() *ocm.Protocol
}

Protocol represents the way of access the resource in the OCM share.

type Protocols

type Protocols []Protocol

Protocols is the list of protocols.

func (Protocols) MarshalJSON

func (p Protocols) MarshalJSON() ([]byte, error)

MarshalJSON implements the Marshaler interface.

func (*Protocols) UnmarshalJSON

func (p *Protocols) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the Unmarshaler interface.

type User

type User struct {
	UserID string `json:"userID"`
	Email  string `json:"email"`
	Name   string `json:"name"`
}

User contains the remote user's information when accepting an invitation.

type WebDAV

type WebDAV struct {
	SharedSecret string   `json:"sharedSecret" validate:"required"`
	Permissions  []string `json:"permissions"  validate:"required,dive,required,oneof=read write share"`
	URL          string   `json:"url"          validate:"required"`
}

WebDAV contains the parameters for the WebDAV protocol.

func (*WebDAV) ToOCMProtocol

func (w *WebDAV) ToOCMProtocol() *ocm.Protocol

ToOCMProtocol convert the protocol to a ocm Protocol struct.

type Webapp

type Webapp struct {
	URITemplate string `json:"uriTemplate" validate:"required"`
	ViewMode    string `json:"viewMode"    validate:"required,dive,required,oneof=view read write"`
}

Webapp contains the parameters for the Webapp protocol.

func (*Webapp) ToOCMProtocol

func (w *Webapp) ToOCMProtocol() *ocm.Protocol

ToOCMProtocol convert the protocol to a ocm Protocol struct.

Jump to

Keyboard shortcuts

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