api

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package api defines the API used by the client and server component. Serialization and marshalling to protobuf is done in the 'proto' package

Index

Constants

View Source
const (
	DEFAULT_ITEM_TYPE = "http://schema.org/Thing"
)

Variables

View Source
var (
	ErrUnimplemented = fmt.Errorf("Unimplemented.")
	ErrInvalidItem   = fmt.Errorf("Invalid item")
)

Functions

func ExpandCurie

func ExpandCurie(curieString string) (*url.URL, error)

Expandeds a CURIE (e.g. <schema:Person> or foaf:name) into a qualified name, e.g. https://schema.org/Person

Types

type ErrInvalidAuthMethod

type ErrInvalidAuthMethod struct {
	Method string
}

func (ErrInvalidAuthMethod) Error

func (e ErrInvalidAuthMethod) Error() string

type ErrInvalidScheme

type ErrInvalidScheme struct {
	Scheme string
}

func (ErrInvalidScheme) Error

func (e ErrInvalidScheme) Error() string

type ErrInvalidUri

type ErrInvalidUri struct {
	Uri string
}

func (ErrInvalidUri) Error

func (e ErrInvalidUri) Error() string

type IRI

type IRI string

IRI: An Internationalized Resource Identifier, similar to a URI https://tools.ietf.org/html/rfc3987

func GetTypeFromStatements

func GetTypeFromStatements(statements []Statement) ([]IRI, error)

func NormalizeIri

func NormalizeIri(iri IRI) (IRI, error)

Ensure that a URL is valid, returning it as a url.URL object

Normalization also performs the following:

  • Expansion of Compact URIs (CURIEs) Both '<schema:Book>' and 'schema:Book' are permitted The list of namespace prefixes supported can be retrieved via GetNamespacePrefixes() (or ltpcli list namespaces) See: https://lov.linkeddata.es/dataset/lov/

func (IRI) Native

func (s IRI) Native() interface{}

func (IRI) String

func (s IRI) String() string

type Item

type Item struct {
	IRI   IRI
	Types []IRI
	// contains filtered or unexported fields
}

func NewItem

func NewItem(itemType IRI) (Item, error)

Used by the CreateItem implementation, or anywhere that the Item model is used. Does not assign a URL, or commit to the store.

func (*Item) AddProperty

func (i *Item) AddProperty(p Property, v Value) error

AddProperty: Append a property=value pair to an item Example:

i.AddProperty(IRI("schema:name"), String("Transformers"))

func (*Item) AddStatement

func (i *Item) AddStatement(s Statement) error

AddStatement: Append a statement (s,p,o,l) to an item

func (Item) AddType

func (i Item) AddType(iri IRI) error

Add a type to an Item If a single empty-string type exists, it will be replaced with the type specified

func (Item) AddTypes

func (i Item) AddTypes(iriList []IRI) error

Add multiple types to an Item

func (Item) GetStatements

func (i Item) GetStatements() ([]Statement, error)

func (Item) ToRequest

func (i Item) ToRequest() (*go_ltp.CreateItemRequest, error)

Return a CreateItemRequest that can be used to instantiate this item

type Property

type Property struct {
	IRI     IRI
	Name    string
	Comment string
}

func NewProperty

func NewProperty(iri IRI) *Property

func (Property) Native

func (p Property) Native() interface{}

func (Property) String

func (p Property) String() string

type Statement

type Statement struct {
	Subject   Value
	Predicate Value
	Object    Value
	Label     Value
}

type String

type String string

func (String) Native

func (s String) Native() interface{}

func (String) String

func (s String) String() string

type Value

type Value interface {
	String() string
	Native() interface{} // Return closest go type
}

See also: https://github.com/cayleygraph/cayley/blob/master/quad/value.go

Directories

Path Synopsis
Package go_ltp is a reverse proxy.
Package go_ltp is a reverse proxy.

Jump to

Keyboard shortcuts

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