types

package
v0.0.0-...-d2a3a15 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2025 License: EUPL-1.2 Imports: 7 Imported by: 0

Documentation

Overview

Package types provides types and interfaces for the API and its backends.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound           = errors.New("not found")
	ErrInvalid            = errors.New("invalid")
	ErrInvalidCredentials = errors.New("invalid credentials")
	ErrBadGateway         = errors.New("bad gateway")
)

Functions

This section is empty.

Types

type AccessManager

type AccessManager interface {
	ListPolicies(ctx context.Context) ([]Policy, error)
	SubmitPolicy(ctx context.Context, policy Policy) error
	DeletePolicy(ctx context.Context, policyID uuid.UUID) error
}

AccessManager is an interface for managing access policies between entities and data.

type AccessType

type AccessType int

AccessType is the type of access to a resource.

const (
	// AccessTypeFull means access to the full resource, including real name.
	AccessTypeFull AccessType = iota
	// AccessTypeAnonymized means access to the anonymized resource.
	AccessTypeAnonymized
	// AccessTypePseudonymized means access to the pseudononymised resource.
	AccessTypePseudonymized
)

type DataspaceConnector

type DataspaceConnector interface {
	ListProviderFiles(ctx context.Context, providerID string) ([]ProviderFile, error)
	GetProviderFileInfo(ctx context.Context, providerID string, fileID string) (ProviderFile, error)
	// TODO: This should return a reader, not bytes, as it might be a large file.
	GetProviderFile(ctx context.Context, providerID string, fileID string) ([]byte, error)
	GetDownloadCredentials(ctx context.Context, providerID string, fileID string) (DownloadCredentials, error)
}

DataspaceConnector is an interface for listing, and receiving data.

type DownloadCredentials

type DownloadCredentials struct {
	AuthenticationType int64  `json:"authentication_type"`
	URL                string `json:"url"`
	Username           string `json:"username"`
	Password           string `json:"password"`
}

type ErrorResponse

type ErrorResponse struct {
	Status string `json:"status"`
	Error  string `json:"error"`
}

ErrorResponse represents a response containing error information.

type Metadata

type Metadata struct {
	Provider  Provider   `json:"provider"`
	UserFiles []UserFile `json:"user_files"`
	Prefix    string
}

type Organization

type Organization struct {
	ID   uuid.UUID `json:"id"`
	Name string    `json:"name"`
}

type Policy

type Policy struct {
	ID         uuid.UUID  `json:"id"`
	Target     Target     `json:"target"`
	Assignee   Provider   `json:"assignee"`
	AccessType AccessType `json:"access_type"`
}

Policy represents a policy, describing the permission givven to a provider for accessing a resource.

func (Policy) Validate

func (p Policy) Validate() error

Validate checks the validity of the policy. TODO: actually validate the policy.

type Provider

type Provider struct {
	ID                   string `json:"id"`
	Name                 string `json:"name"`
	Description          string `json:"description"`
	LogoURI              string `json:"logo_uri"`
	ContactInformation   string `json:"contact_information"`
	VerifiableCredential string `json:"verifiable_credential"`
	MetadataKey          string // Only used as S3 object reference
	ProviderUrl          string `json:"provider_url"`
	PublicKey            string `json:"public_key"`
}

Provider represents a provider of a resource.

type ProviderFile

type ProviderFile struct {
	ID          string   `json:"id"`
	Name        string   `json:"name"`
	Description string   `json:"description"`
	CreatedAt   int64    `json:"created_at"`
	MimeType    string   `json:"mime_type"`
	Size        int64    `json:"size"`
	Provider    Provider `json:"provider"`
	Key         string
}

ProviderFile represents a file hosted by a provider.

func (ProviderFile) Validate

func (pf ProviderFile) Validate() error

Validate checks the validity of the ProviderFile. TODO: actually validate the ProviderFile.

type ProviderLister

type ProviderLister interface {
	ListProviders(ctx context.Context) ([]Provider, error)
	GetProvider(ctx context.Context, providerID string) (Provider, error)
	GetProviderURL(ctx context.Context, providerID string) (string, error)
}

ProviderLister is an interface for looking up providers.

type ResearchData

type ResearchData struct {
	Name        string     `json:"name"`
	Description string     `json:"description"`
	DataType    string     `json:"data_type"`
	AccessType  AccessType `json:"access_type"`
}

ResearchData represents data and the type of access that a study wants to use for its research.

type S3Connection

type S3Connection struct {
	S3Client *minio.Client
	Bucket   string
}

func (*S3Connection) EnrichUserFile

func (s3c *S3Connection) EnrichUserFile(
	context context.Context,
	userFile UserFile,
	metadata Metadata,
) (ProviderFile, error)

func (*S3Connection) GetBytes

func (s3c *S3Connection) GetBytes(context context.Context, name string) ([]byte, error)

func (*S3Connection) GetMetadataObject

func (s3c *S3Connection) GetMetadataObject(context context.Context, name string) (*Metadata, error)

func (*S3Connection) GetMetadataObjects

func (s3c *S3Connection) GetMetadataObjects(context context.Context) ([]Metadata, error)

type ShareManager

type ShareManager interface {
	SubmitShare(ctx context.Context, share ShareRequest) (ShareResponse, error)
}

ShareManager is an interfacd for managing sharing between non-dataspace entities and data.

type ShareRequest

type ShareRequest struct {
	Target Target `json:"target"`
	Key    string `json:"key"`
}

ShareRequest represents a request to share a resource.

func (ShareRequest) Validate

func (sr ShareRequest) Validate() error

Validate checks the validity of the ShareRequest. TODO: actually validate the ShareRequest.

type ShareResponse

type ShareResponse struct {
	TTL         int64  `json:"ttl"`
	DownloadURI string `json:"download_uri"`
	BearerToken string `json:"bearer_token"`
}

ShareResponse represents the response to a share request.

type Study

type Study struct {
	ID                 uuid.UUID      `json:"id"`
	Organization       Organization   `json:"organization"`
	Name               string         `json:"name"`
	Description        string         `json:"description"`
	DescriptionSummary string         `json:"description_summary"`
	StudyUri           string         `json:"study_uri"`
	StudyStart         int64          `json:"study_start"`
	StudyEnd           int64          `json:"study_end"`
	ResearchData       []ResearchData `json:"research_data"`
}

Study represents a study.

type StudyLister

type StudyLister interface {
	ListStudies(ctx context.Context) ([]Study, error)
	GetStudy(ctx context.Context, studyID uuid.UUID) (Study, error)
	ListStudyFiles(ctx context.Context, studyID uuid.UUID) ([]ProviderFile, error)
}

StudyLister is an interface for looking up studies.

type StudySharedFile

type StudySharedFile struct {
	ID          uuid.UUID `json:"id"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
}

type SuccessResponse

type SuccessResponse struct {
	Status string `json:"status"`
}

SuccessResponse represents a response containing success information.

type Target

type Target struct {
	ProviderID string    `json:"provider_id"`
	FileID     uuid.UUID `json:"file_id"`
}

Target represents the target of a policy permission request..

type UserFile

type UserFile struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	MimeType    string `json:"mime_type"`
}

func (*UserFile) ToProviderFile

func (uf *UserFile) ToProviderFile(createdAt int64, size int64, provider Provider, key string) ProviderFile

type Validator

type Validator interface {
	Validate() error
}

Validator is the interface all validator implementations must implement.

Jump to

Keyboard shortcuts

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