api

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 14, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package api contains generic implementation of APIs to expose archivekeep functionality from application servers.

This package contains common constructs for all APIs. The HTTP and GRPC APIs are available in sub-packages.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotAuthorized should be returned if user can see resource, but can't perform the operation.
	//
	// Be cautious to not return this error for invocations, where user can't access a resource all. In such cases
	// ErrNotFound might be more appropriate to prevent information leak informing, that resource exists, but user
	// can't access it.
	//
	// TODO: API implementation to provide option.rewriteNotAuthorized to "not found or not authorized" for all
	// not authorized and not found errors to signal user authorization might be needed but won't leak information.
	ErrNotAuthorized = errors.New("not authorized")

	ErrNotFound       = errors.New("not found")
	ErrNotImplemented = errors.New("not implemented")
)

Functions

This section is empty.

Types

type ArchiveAccessor

type ArchiveAccessor interface {
	OpenReader() (archive.Reader, error)
	OpenWriter() (archive.Writer, error)

	OpenReadWriter() (archive.ReadWriter, error)

	// GetThumbnail should return a thumbnail for file at given path
	// TODO: add support for image formats (JPEG, WEBP,...) and move to more appropriate place
	GetThumbnail(ctx context.Context, filePath string) (io.ReadCloser, error)
	// contains filtered or unexported methods
}

type ArchiveDetails

type ArchiveDetails struct {
	ID    string
	Owner string

	ArchiveName string
}

type ArchivePermissionService added in v0.1.3

type ArchivePermissionService interface {
	ListArchivePermissions(ctx context.Context, request ListArchivePermissionsRequest) (ListArchivePermissionsResult, error)

	CreateArchivePermission(ctx context.Context, request CreateArchivePermissionRequest) (ArchivePermissionsDetails, error)

	DeletePermission(ctx context.Context, request DeleteArchivePermissionRequest) error
}

type ArchivePermissionsDetails added in v0.1.3

type ArchivePermissionsDetails struct {
	ArchiveID    string
	PermissionID string

	// SubjectName should represent resource name having access to the archive, i.e.
	// it could be users-by-email/someone@there.com
	SubjectName string
}

type ArchiveService

type ArchiveService interface {
	ListArchives(ctx context.Context, request ListArchivesRequest) (ListArchivesResult, error)
	GetArchive(ctx context.Context, id string) (ArchiveDetails, error)

	GetArchiveAccessor(ctx context.Context, id string) (ArchiveAccessor, error)
	// contains filtered or unexported methods
}

ArchiveService is an application service exposing access to archives.

Authorization MUST be performed by ArchiveService on each method call. If a method returns a rich object, like GetArchiveAccessor, then implementation of these objects MUST ensure correct access control policies are applied for the user, for which the object was returned.

type CreateArchivePermissionRequest added in v0.1.3

type CreateArchivePermissionRequest struct {
	ArchiveID string

	// SubjectName to share archive with, see SubjectName in ArchivePermissionsDetails
	SubjectName string
}

type CreatePersonalAccessTokenRequest

type CreatePersonalAccessTokenRequest struct {
	Name string
}

type DeleteArchivePermissionRequest added in v0.1.3

type DeleteArchivePermissionRequest struct {
	ArchiveID    string
	PermissionID string
}

type ListArchivePermissionsRequest added in v0.1.3

type ListArchivePermissionsRequest struct {
	ArchiveID string
}

type ListArchivePermissionsResult added in v0.1.3

type ListArchivePermissionsResult struct {
	ArchivePermissions []ArchivePermissionsDetails
}

type ListArchivesRequest

type ListArchivesRequest struct{}

type ListArchivesResult

type ListArchivesResult struct {
	Archives []ArchiveDetails
}

type PersonalAccessToken

type PersonalAccessToken struct {
	ID             string
	Name           string
	Token          string
	TokenLastEight string
}

type PersonalAccessTokenService

type PersonalAccessTokenService interface {
	CreatePersonalAccessToken(ctx context.Context, request *CreatePersonalAccessTokenRequest) (*PersonalAccessToken, error)
}

type TestArchive

type TestArchive struct {
	UnimplementedArchiveAccessor

	Id          string
	DisplayName string
	A           archive.ReadWriter
}

func (TestArchive) OpenReadWriter

func (t TestArchive) OpenReadWriter() (archive.ReadWriter, error)

func (TestArchive) OpenReader

func (t TestArchive) OpenReader() (archive.Reader, error)

func (TestArchive) OpenWriter

func (t TestArchive) OpenWriter() (archive.Writer, error)

type TestSingleArchiveService

type TestSingleArchiveService struct {
	UnimplementedArchiveService

	A TestArchive
}

func (*TestSingleArchiveService) GetArchiveAccessor

func (t *TestSingleArchiveService) GetArchiveAccessor(ctx context.Context, id string) (ArchiveAccessor, error)

func (*TestSingleArchiveService) ListArchives

type UnimplementedArchiveAccessor

type UnimplementedArchiveAccessor struct {
}

func (UnimplementedArchiveAccessor) GetThumbnail

func (UnimplementedArchiveAccessor) OpenReadWriter

func (_ UnimplementedArchiveAccessor) OpenReadWriter() (archive.ReadWriter, error)

func (UnimplementedArchiveAccessor) OpenReader

func (UnimplementedArchiveAccessor) OpenWriter

type UnimplementedArchivePermissionService added in v0.1.3

type UnimplementedArchivePermissionService struct{}

func (UnimplementedArchivePermissionService) CreateArchivePermission added in v0.1.3

func (UnimplementedArchivePermissionService) DeletePermission added in v0.1.3

func (UnimplementedArchivePermissionService) ListArchivePermissions added in v0.1.3

type UnimplementedArchiveService

type UnimplementedArchiveService struct {
}

func (UnimplementedArchiveService) GetArchive

func (UnimplementedArchiveService) GetArchiveAccessor

func (UnimplementedArchiveService) ListArchives

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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