easclient

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: MIT Imports: 9 Imported by: 0

README

EAS Client

This project implements an HTTP client for the API of the Otris EAS developed by Otris AG.

Testing

Since this is an API client for a proprietary software, we have decided to not include any docker containers / images which would allow you to test the client against a running EAS instance.

That is why the CI pipeline skips tests which require a running EAS instance.

Documentation

Index

Constants

View Source
const UserClaimsKey = "easclient-user-claims-key"

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigurationParameter

type ConfigurationParameter struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type ConfigurationTemplate

type ConfigurationTemplate struct {
	Name       string                   `json:"name"`
	Parameters []ConfigurationParameter `json:"parameters"`
}

type PutStoreRequest

type PutStoreRequest struct {
	ConfigurationTemplate `json:"configurationTemplate"`
}

type Record

type Record struct {
	HeaderFields struct {
		DocumentType           string    `json:"_documentType"`
		MasterId               uuid.UUID `json:"_masterId"`
		ArchiveDateTime        time.Time `json:"_archiveDateTime"`
		Id                     uuid.UUID `json:"_id"`
		Version                string    `json:"_version"`
		ArchiverLogin          string    `json:"_archiverLogin"`
		InitialArchiverLogin   string    `json:"_initialArchiverLogin"`
		InitialArchiveDateTime time.Time `json:"_initialArchiveDateTime"`
	} `json:"headerFields"`
	RecordFields map[string]string   `json:"recordFields"`
	Attachments  []*RecordAttachment `json:"attachments"`
}

func (*Record) GetHeaderField added in v0.1.2

func (rec *Record) GetHeaderField(name string) string

GetHeaderField returns either the value of the given header field or an empty string if the field does not exist.

type RecordAttachment

type RecordAttachment struct {
	Body            string    `json:"body"`
	Name            string    `json:"name"`
	Size            string    `json:"size"`
	Register        string    `json:"register"`
	Author          string    `json:"author"`
	Type            string    `json:"type"`
	DocumentType    string    `json:"documentType"`
	Id              uuid.UUID `json:"id"`
	FileId          uuid.UUID `json:"fileId"`
	MasterId        uuid.UUID `json:"masterId"`
	Version         string    `json:"version"`
	ArchiveDateTime time.Time `json:"archiveDateTime"`
}

type RequestHeader

type RequestHeader string
const (
	HeaderUser         RequestHeader = "x-otris-eas-user"
	HeaderUserFullname RequestHeader = "x-otris-eas-user-fullname"
	HeaderTokens       RequestHeader = "x-otris-eas-tokens"
)

type ServerClient

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

func NewServerClient

func NewServerClient(c *resty.Client) *ServerClient

func (*ServerClient) PutStore

func (c *ServerClient) PutStore(ctx context.Context, storeName string, request *PutStoreRequest) error

type StoreClient

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

func NewStoreClient

func NewStoreClient(c *resty.Client) *StoreClient

func (*StoreClient) GetRecord

func (c *StoreClient) GetRecord(ctx context.Context, id uuid.UUID) (*Record, error)

func (*StoreClient) GetRecordAttachment

func (c *StoreClient) GetRecordAttachment(ctx context.Context, writer io.Writer, recordID, attachmentID uuid.UUID) (int64, error)

GetRecordAttachment retrieves the actual attachment. It is written to the given io.Writer.

This returns the number of bytes written and an error if any.

func (*StoreClient) GetStoreStatus

func (c *StoreClient) GetStoreStatus(ctx context.Context) (*StoreStatus, error)

type StoreStatus

type StoreStatus struct {
	Registry struct {
		AllRecords         int `json:"allRecords"`
		IndexedRecords     int `json:"indexedRecords"`
		AllAttachments     int `json:"allAttachments"`
		IndexedAttachments int `json:"indexedAttachments"`
	} `json:"registry"`
	Index struct {
		Documents    int  `json:"documents"`
		IsCurrent    bool `json:"isCurrent"`
		HasDeletions bool `json:"hasDeletions"`
		Records      int  `json:"records"`
		Attachments  int  `json:"attachments"`
	} `json:"index"`
	Capacity struct {
		Maximum     int64     `json:"maximum"`
		Utilized    float64   `json:"utilized"`
		GrowthRate  float64   `json:"growthRate"`
		ExpectedEnd time.Time `json:"expectedEnd"`
		Lifetime    int       `json:"lifetime"`
	} `json:"capacity"`
	Periods []struct {
		Start    string `json:"start"`
		End      string `json:"end"`
		Registry struct {
			AllRecords         int `json:"allRecords"`
			IndexedRecords     int `json:"indexedRecords"`
			AllAttachments     int `json:"allAttachments"`
			IndexedAttachments int `json:"indexedAttachments"`
		} `json:"registry"`
		Index struct {
			Records     int `json:"records"`
			Attachments int `json:"attachments"`
		} `json:"index"`
		Capacity struct {
			Utilized float64 `json:"utilized"`
		} `json:"capacity"`
	} `json:"periods"`
}

type User

type User string

User is a custom type to represent one of the four EAS user instances.

const (
	// UserAdmin is the administrator which most permissions.
	UserAdmin User = "eas_administrator"
	// UserKeeper is responsible for auditing, moderating, etc.
	UserKeeper User = "eas_keeper"
	// UserUser is the default user being able to read and write.
	UserUser User = "eas_user"
	// UserGuest is a guest user.
	UserGuest User = "eas_guest"
)

type UserClaims

type UserClaims struct {
	// UserId - Technischer Identifikator des Nutzers, der im Host-System die Anfrage ausgelöst hat.
	UserId string `json:"user,omitempty"`

	// UserFullname - Optionaler, vollständiger Name des Nutzers, der im Host-System die Anfrage ausgelöst hat
	UserFullname string `json:"user_fullname,omitempty"`

	// Tokens - Securitytokens (Gruppenzugehörigkeit) -getrennt durch Kommata- des Nutzers, der im Host-System den Request
	// ausgelöst hat.
	Tokens []string `json:"tokens,omitempty"`
}

UserClaims aggregates all claims that are scoped to an EAS archive user.

func NewUserClaims

func NewUserClaims(userId string) *UserClaims

func UserClaimsFromContext

func UserClaimsFromContext(ctx context.Context) *UserClaims

func (*UserClaims) SetOnContext

func (claims *UserClaims) SetOnContext(ctx context.Context) context.Context

func (*UserClaims) SetOnHeader

func (claims *UserClaims) SetOnHeader(header http.Header)

SetOnHeader sets all possible eas.RequestHeader based on this UserClaims

Directories

Path Synopsis
Package eastest contains test helpers for testing with the EAS.
Package eastest contains test helpers for testing with the EAS.

Jump to

Keyboard shortcuts

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