client

package
v0.0.85 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTooManyRequests = fmt.Errorf("Too Many Requests")

ErrTooManyRequests error representing too many requests to the API

Functions

This section is empty.

Types

type Column added in v0.0.67

type Column struct {
	Name string `json:"name"`
	Type string `json:"type,omitempty"`
}

Column a column as returned by the graphdb api.

type DeleteGraphAssetRequestBody

type DeleteGraphAssetRequestBody struct {
	Assets []knowledge.Asset `json:"assets"`
}

DeleteGraphAssetRequestBody a request body for the asset removal

type DeleteGraphRelationRequestBody

type DeleteGraphRelationRequestBody struct {
	Relations []knowledge.Relation `json:"relations"`
}

DeleteGraphRelationRequestBody a request body for the relation removal

type GraphAPI

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

GraphAPI represent the graph API from a data source point of view

func NewGraphAPI

func NewGraphAPI(options GraphAPIOptions) *GraphAPI

NewGraphAPI create an emitter of graph

func (*GraphAPI) CreateTransaction

func (gapi *GraphAPI) CreateTransaction() (*Transaction, error)

CreateTransaction create a full graph transaction. This kind of transaction will diff the new graph with previous version of it.

func (*GraphAPI) Query added in v0.0.67

func (gapi *GraphAPI) Query(ctx context.Context, q string, includeSources bool) (*QueryResponse, error)

func (*GraphAPI) ReadCurrentGraph

func (gapi *GraphAPI) ReadCurrentGraph() (*knowledge.Graph, error)

ReadCurrentGraph read the current graph stored in graph kb

type GraphAPIOptions

type GraphAPIOptions struct {
	// URL to GraphKB
	URL string
	// Auth token for this data source.
	AuthToken string

	BasicAuthUsername string
	BasicAuthPassword string

	// Skip verifying the certificate when using https
	SkipVerify bool

	// The level of parallelization for streaming updates, i.e., number of HTTP requests sent in parallel.
	Parallelization int

	// The size of a chunk of updates, i.e., number of assets or relations sent in one HTTP request to the streaming API.
	ChunkSize int

	// Max number of retries before giving up (default is 10)
	MaxRetries int
	// The base delay between retries (default is 5 seconds). This delay is multiplied by the backoff factor.
	RetryDelay time.Duration

	// The backoff factor (default is 1.01)
	RetryBackoffFactor float64

	// The API stores the lastly pushed graph in memory to avoid fetching the entire data at every run which can be heavy on
	// DB if importers run very incrementally. The anti entropy duration is a duration before forcing a synchronization against
	// the server even though the graph is still stored in memory.
	AntiEntropyDuration time.Duration
}

GraphAPIOptions options to pass to build graph API

type GraphClient

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

GraphClient is a client of the GraphKB API

func NewGraphClient

func NewGraphClient(URL, authToken, basicAuthUser, basicAuthPass string, skipVerify bool) *GraphClient

NewGraphClient create a client of the GraphKB API

func (*GraphClient) DeleteAssets added in v0.0.25

func (gc *GraphClient) DeleteAssets(assets []knowledge.Asset) error

DeleteAssets send asset removal operations to the API

func (*GraphClient) DeleteRelations added in v0.0.25

func (gc *GraphClient) DeleteRelations(relations []knowledge.Relation) error

DeleteRelations send relation removal operations to the API

func (*GraphClient) InsertAssets added in v0.0.25

func (gc *GraphClient) InsertAssets(assets []knowledge.Asset) error

InsertAssets send asset insert operations to the API

func (*GraphClient) InsertRelations added in v0.0.25

func (gc *GraphClient) InsertRelations(relations []knowledge.Relation) error

InsertRelations send relation insert operations to the API

func (*GraphClient) ReadCurrentGraph

func (gc *GraphClient) ReadCurrentGraph() (*knowledge.Graph, error)

ReadCurrentGraph read the current graph stored in graph kb

func (*GraphClient) UpdateSchema

func (gc *GraphClient) UpdateSchema(sg schema.SchemaGraph) error

UpdateSchema send a graph schema update to the API

type Item added in v0.0.67

type Item map[string]any

func (Item) Asset added in v0.0.67

func (ra Item) Asset() knowledge.AssetWithID

func (Item) Property added in v0.0.82

func (ra Item) Property() knowledge.Property

func (Item) Relation added in v0.0.67

func (ra Item) Relation() knowledge.RelationWithID

func (Item) Sources added in v0.0.79

func (ra Item) Sources() []string

type PutGraphAssetRequestBody

type PutGraphAssetRequestBody struct {
	Assets []knowledge.Asset `json:"assets"`
}

PutGraphAssetRequestBody a request body for the asset upsert

type PutGraphRelationRequestBody

type PutGraphRelationRequestBody struct {
	Relations []knowledge.Relation `json:"relations"`
}

PutGraphRelationRequestBody a request body for the relation upsert

type PutGraphSchemaRequestBody

type PutGraphSchemaRequestBody struct {
	Schema schema.SchemaGraph `json:"schema"`
}

PutGraphSchemaRequestBody a request body for the schema update

type QueryRequestBody added in v0.0.67

type QueryRequestBody struct {
	Q              string `json:"q"`
	IncludeSources bool   `json:"include_sources"`
}

type QueryResponse added in v0.0.67

type QueryResponse struct {
	Columns []Column
	Items   [][]Item
}

type Transaction

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

Transaction represent a transaction generating updates by diffing the provided graph against the previous version.

func (*Transaction) Bind

func (cgt *Transaction) Bind(asset string, assetType schema.AssetType)

Bind bind one asset to an asset type from the schema

func (*Transaction) Commit

func (cgt *Transaction) Commit() error

Commit commit the transaction and gives ownership to the source for caching.

func (*Transaction) Relate

func (cgt *Transaction) Relate(from string, relationType schema.RelationType, to string)

Relate create a relation between two assets

Jump to

Keyboard shortcuts

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