svc

package
v2.0.0-beta2 Latest Latest
Warning

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

Go to latest
Published: May 25, 2022 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoSpaceFoundMessage           = "space with id `%s` not found"
	ListStorageSpacesTransportErr = "transport error sending list storage spaces grpc request"
	ListStorageSpacesReturnsErr   = "list storage spaces grpc request returns an errorcode in the response"
	ReadmeSpecialFolderName       = "readme"
	SpaceImageSpecialFolderName   = "image"
)
View Source
const (
	// HeaderPurge defines the header name for the purge header.
	HeaderPurge = "Purge"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GatewayClient

type GatewayClient interface {

	// Authenticates a user.
	Authenticate(ctx context.Context, in *gateway.AuthenticateRequest, opts ...grpc.CallOption) (*gateway.AuthenticateResponse, error)
	// Returns the home path for the given authenticated user.
	// When a user has access to multiple storage providers, one of them is the home.
	GetHome(ctx context.Context, in *provider.GetHomeRequest, opts ...grpc.CallOption) (*provider.GetHomeResponse, error)
	// GetPath does a path lookup for a resource by ID
	GetPath(ctx context.Context, in *provider.GetPathRequest, opts ...grpc.CallOption) (*provider.GetPathResponse, error)
	// Returns a list of resource information
	// for the provided reference.
	// MUST return CODE_NOT_FOUND if the reference does not exists.
	ListContainer(ctx context.Context, in *provider.ListContainerRequest, opts ...grpc.CallOption) (*provider.ListContainerResponse, error)
	// Returns the resource information at the provided reference.
	// MUST return CODE_NOT_FOUND if the reference does not exist.
	Stat(ctx context.Context, in *provider.StatRequest, opts ...grpc.CallOption) (*provider.StatResponse, error)
	// Initiates the download of a file using an
	// out-of-band data transfer mechanism.
	InitiateFileDownload(ctx context.Context, in *provider.InitiateFileDownloadRequest, opts ...grpc.CallOption) (*gateway.InitiateFileDownloadResponse, error)
	// Creates a storage space.
	CreateStorageSpace(ctx context.Context, in *provider.CreateStorageSpaceRequest, opts ...grpc.CallOption) (*provider.CreateStorageSpaceResponse, error)
	// Lists storage spaces.
	ListStorageSpaces(ctx context.Context, in *provider.ListStorageSpacesRequest, opts ...grpc.CallOption) (*provider.ListStorageSpacesResponse, error)
	// Updates a storage space.
	UpdateStorageSpace(ctx context.Context, in *provider.UpdateStorageSpaceRequest, opts ...grpc.CallOption) (*provider.UpdateStorageSpaceResponse, error)
	// Deletes a storage space.
	DeleteStorageSpace(ctx context.Context, in *provider.DeleteStorageSpaceRequest, opts ...grpc.CallOption) (*provider.DeleteStorageSpaceResponse, error)
	// Returns the quota available under the provided
	// reference.
	// MUST return CODE_NOT_FOUND if the reference does not exist
	// MUST return CODE_RESOURCE_EXHAUSTED on exceeded quota limits.
	GetQuota(ctx context.Context, in *gateway.GetQuotaRequest, opts ...grpc.CallOption) (*provider.GetQuotaResponse, error)
}

GatewayClient is the subset of the gateway.GatewayAPIClient that is being used to interact with the gateway

type GetGatewayServiceClientFunc

type GetGatewayServiceClientFunc func() (GatewayClient, error)

GetGatewayServiceClientFunc is a callback used to pass in a mock during testing

type Graph

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

Graph defines implements the business logic for Service.

func (Graph) ChangeOwnPassword

func (g Graph) ChangeOwnPassword(w http.ResponseWriter, r *http.Request)

ChangeOwnPassword implements the Service interface. It allows the user to change its own password

func (Graph) CreateDrive

func (g Graph) CreateDrive(w http.ResponseWriter, r *http.Request)

CreateDrive creates a storage drive (space).

func (Graph) DeleteDrive

func (g Graph) DeleteDrive(w http.ResponseWriter, r *http.Request)

func (Graph) DeleteGroup

func (g Graph) DeleteGroup(w http.ResponseWriter, r *http.Request)

DeleteGroup implements the Service interface.

func (Graph) DeleteGroupMember

func (g Graph) DeleteGroupMember(w http.ResponseWriter, r *http.Request)

DeleteGroupMember implements the Service interface.

func (Graph) DeleteUser

func (g Graph) DeleteUser(w http.ResponseWriter, r *http.Request)

func (Graph) GetAllDrives

func (g Graph) GetAllDrives(w http.ResponseWriter, r *http.Request)

GetAllDrives lists all drives, including other user's drives, if the current user has the permission.

func (Graph) GetDrives

func (g Graph) GetDrives(w http.ResponseWriter, r *http.Request)

GetDrives lists all drives the current user has access to

func (Graph) GetExtendedSpaceProperties

func (g Graph) GetExtendedSpaceProperties(ctx context.Context, baseURL *url.URL, space *storageprovider.StorageSpace) []libregraph.DriveItem

GetExtendedSpaceProperties reads properties from the opaque and transforms them into driveItems

func (Graph) GetGatewayClient

func (g Graph) GetGatewayClient() GatewayClient

GetClient returns a gateway client to talk to reva

func (Graph) GetGroup

func (g Graph) GetGroup(w http.ResponseWriter, r *http.Request)

GetGroup implements the Service interface.

func (Graph) GetGroupMembers

func (g Graph) GetGroupMembers(w http.ResponseWriter, r *http.Request)

func (Graph) GetGroups

func (g Graph) GetGroups(w http.ResponseWriter, r *http.Request)

GetGroups implements the Service interface.

func (Graph) GetHTTPClient

func (g Graph) GetHTTPClient() HTTPClient

GetClient returns a gateway client to talk to reva

func (Graph) GetMe

func (g Graph) GetMe(w http.ResponseWriter, r *http.Request)

GetMe implements the Service interface.

func (Graph) GetRootDriveChildren

func (g Graph) GetRootDriveChildren(w http.ResponseWriter, r *http.Request)

GetRootDriveChildren implements the Service interface.

func (Graph) GetSingleDrive

func (g Graph) GetSingleDrive(w http.ResponseWriter, r *http.Request)

GetSingleDrive does a lookup of a single space by spaceId

func (Graph) GetUser

func (g Graph) GetUser(w http.ResponseWriter, r *http.Request)

GetUser implements the Service interface.

func (Graph) GetUsers

func (g Graph) GetUsers(w http.ResponseWriter, r *http.Request)

GetUsers implements the Service interface.

func (Graph) ListStorageSpacesWithFilters

func (g Graph) ListStorageSpacesWithFilters(ctx context.Context, filters []*storageprovider.ListStorageSpacesRequest_Filter, unrestricted bool) (*storageprovider.ListStorageSpacesResponse, error)

ListStorageSpacesWithFilters List Storage Spaces using filters

func (Graph) PatchGroup

func (g Graph) PatchGroup(w http.ResponseWriter, r *http.Request)

PatchGroup implements the Service interface.

func (Graph) PatchUser

func (g Graph) PatchUser(w http.ResponseWriter, r *http.Request)

PatchUser implements the Service Interface. Updates the specified attributes of an ExistingUser

func (Graph) PostGroup

func (g Graph) PostGroup(w http.ResponseWriter, r *http.Request)

PostGroup implements the Service interface.

func (Graph) PostGroupMember

func (g Graph) PostGroupMember(w http.ResponseWriter, r *http.Request)

PostGroupMember implements the Service interface.

func (Graph) PostUser

func (g Graph) PostUser(w http.ResponseWriter, r *http.Request)

func (Graph) ServeHTTP

func (g Graph) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the Service interface.

func (Graph) UpdateDrive

func (g Graph) UpdateDrive(w http.ResponseWriter, r *http.Request)

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient is the subset of the http.Client that is being used to interact with the download gateway

type Option

type Option func(o *Options)

Option defines a single option function.

func Config

func Config(val *config.Config) Option

Config provides a function to set the config option.

func EventsPublisher

func EventsPublisher(val events.Publisher) Option

EventsPublisher provides a function to set the EventsPublisher option.

func Logger

func Logger(val log.Logger) Option

Logger provides a function to set the logger option.

func Middleware

func Middleware(val ...func(http.Handler) http.Handler) Option

Middleware provides a function to set the middleware option.

func RoleManager

func RoleManager(val *roles.Manager) Option

RoleManager provides a function to set the RoleManager option.

func RoleService

func RoleService(val settingssvc.RoleService) Option

RoleService provides a function to set the RoleService option.

func WithGatewayClient

func WithGatewayClient(val GatewayClient) Option

WithGatewayClient provides a function to set the gateway client option.

func WithHTTPClient

func WithHTTPClient(val HTTPClient) Option

WithHTTPClient provides a function to set the http client option.

func WithIdentityBackend

func WithIdentityBackend(val identity.Backend) Option

WithIdentityBackend provides a function to set the IdentityBackend option.

type Options

type Options struct {
	Logger          log.Logger
	Config          *config.Config
	Middleware      []func(http.Handler) http.Handler
	GatewayClient   GatewayClient
	IdentityBackend identity.Backend
	HTTPClient      HTTPClient
	RoleService     settingssvc.RoleService
	RoleManager     *roles.Manager
	EventsPublisher events.Publisher
}

Options defines the available options for this package.

type Publisher

type Publisher interface {
	Publish(string, interface{}, ...mevents.PublishOption) error
}

Publisher is the interface for events publisher

type Service

type Service interface {
	ServeHTTP(http.ResponseWriter, *http.Request)
	GetMe(http.ResponseWriter, *http.Request)
	GetUsers(http.ResponseWriter, *http.Request)
	GetUser(http.ResponseWriter, *http.Request)
	PostUser(http.ResponseWriter, *http.Request)
	DeleteUser(http.ResponseWriter, *http.Request)
	PatchUser(http.ResponseWriter, *http.Request)
	ChangeOwnPassword(http.ResponseWriter, *http.Request)

	GetGroups(http.ResponseWriter, *http.Request)
	GetGroup(http.ResponseWriter, *http.Request)
	PostGroup(http.ResponseWriter, *http.Request)
	PatchGroup(http.ResponseWriter, *http.Request)
	DeleteGroup(http.ResponseWriter, *http.Request)
	GetGroupMembers(http.ResponseWriter, *http.Request)
	PostGroupMember(http.ResponseWriter, *http.Request)
	DeleteGroupMember(http.ResponseWriter, *http.Request)

	GetDrives(w http.ResponseWriter, r *http.Request)
}

Service defines the extension handlers.

func NewInstrument

func NewInstrument(next Service, metrics *metrics.Metrics) Service

NewInstrument returns a service that instruments metrics.

func NewLogging

func NewLogging(next Service, logger log.Logger) Service

NewLogging returns a service that logs messages.

func NewService

func NewService(opts ...Option) Service

NewService returns a service implementation for Service.

func NewTracing

func NewTracing(next Service) Service

NewTracing returns a service that instruments traces.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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