annotations

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// NoAnnotationsMsg is error message used when there are no processed annotations.
	NoAnnotationsMsg = "No annotations found"
	// UPPBadRequestMsg is error message used when UPP annotations endpoint returns bad request.
	UPPBadRequestMsg = "UPP responded with a client error"
	// UPPNotFoundMsg is error message used when UPP annotations endpoint returns not found.
	UPPNotFoundMsg = "UPP responded with not found"
	// UPPServiceUnavailableMsg is error message used when UPP annotations endpoint returns http error code
	// different from bad request and not found
	UPPServiceUnavailableMsg = "Service unavailable"
)
View Source
const DocumentHashHeader = "Document-Hash"
View Source
const PreviousDocumentHashHeader = "Previous-Document-Hash"

Variables

View Source
var ErrGTGNotOK = errors.New("gtg returned a non-200 HTTP status")
View Source
var ErrUnexpectedStatusRead = errors.New("annotations RW returned an unexpected HTTP status code in read operation")
View Source
var ErrUnexpectedStatusWrite = errors.New("annotations RW returned an unexpected HTTP status code in write operation")

Functions

func NewCanonicalAnnotationSorter

func NewCanonicalAnnotationSorter(ann []Annotation) sort.Interface

Types

type Annotation

type Annotation struct {
	Predicate  string `json:"predicate"`
	ConceptId  string `json:"id"`
	ApiUrl     string `json:"apiUrl,omitempty"`
	Type       string `json:"type,omitempty"`
	PrefLabel  string `json:"prefLabel,omitempty"`
	IsFTAuthor bool   `json:"isFTAuthor,omitempty"`
}

type Annotations

type Annotations struct {
	Annotations []Annotation `json:"annotations"`
}

type Augmenter

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

func NewAugmenter

func NewAugmenter(api concept.ReadAPI) *Augmenter

func (*Augmenter) AugmentAnnotations

func (a *Augmenter) AugmentAnnotations(ctx context.Context, canonicalAnnotations []Annotation) ([]Annotation, error)

type Canonicalizer

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

func NewCanonicalizer

func NewCanonicalizer(sorterFactory func(ann []Annotation) sort.Interface) *Canonicalizer

func (*Canonicalizer) Canonicalize

func (c *Canonicalizer) Canonicalize(in []Annotation) []Annotation

type RW

type RW interface {
	Read(ctx context.Context, contentUUID string) (*Annotations, string, bool, error)
	Write(ctx context.Context, contentUUID string, annotations *Annotations, hash string) (string, error)
	Endpoint() string
	GTG() error
}

func NewRW

func NewRW(client *http.Client, endpoint string) RW

type UPPAnnotationsAPI

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

UPPAnnotationsAPI retrieves published annotations from UPP.

func NewUPPAnnotationsAPI

func NewUPPAnnotationsAPI(client *http.Client, endpoint string, username string, password string) *UPPAnnotationsAPI

NewUPPAnnotationsAPI initializes UPPAnnotationsAPI by given http client, the url of the UPP public endpoint for getting published annotations and UPP API key.

func (*UPPAnnotationsAPI) Endpoint

func (api *UPPAnnotationsAPI) Endpoint() string

Endpoint retrieves the template for UPP annotations endpoint

func (*UPPAnnotationsAPI) GTG

func (api *UPPAnnotationsAPI) GTG() error

GTG is making call the UPP annotations endpoint for predefined synthetic content UUID and check that response is returned

func (*UPPAnnotationsAPI) GetAll

func (api *UPPAnnotationsAPI) GetAll(ctx context.Context, contentUUID string) ([]Annotation, error)

GetAll retrieves the list of published annotations for given contentUUID. The returned list contains the annotations returned by UPP without filtering.

func (*UPPAnnotationsAPI) GetAllButV2

func (api *UPPAnnotationsAPI) GetAllButV2(ctx context.Context, contentUUID string) ([]Annotation, error)

GetAllButV2 retrieves the list of published annotations for given contentUUID but filtering v2 annotations.

type UPPError

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

UPPError encapsulates error information for errors originating from calls to UPP annotations endpoint.

func NewUPPError added in v1.4.9

func NewUPPError(msg string, status int, uppBody []byte) UPPError

NewUPPError initializes UPPError

func (UPPError) Error

func (ue UPPError) Error() string

Error returns the error message.

func (UPPError) Status

func (ue UPPError) Status() int

Status returns the http status code returned by the call to the UPP annotations endpoint.

func (UPPError) UPPBody

func (ue UPPError) UPPBody() []byte

UPPBody returns the http response body returned by the call to the UPP annotations endpoint.

Jump to

Keyboard shortcuts

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