This repository was archived by the owner on Feb 4, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinterface.go
67 lines (58 loc) · 2.54 KB
/
interface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package appsearch
import (
"context"
"github.com/lithiumlabcompany/appsearch/pkg/schema"
)
// DocumentAPI document api
type DocumentAPI interface {
// Patch a list of documents. Every document must contain "id".
// Every document is processed separately.
// Documents without ID will be rejected.
// Non-existent documents will be rejected.
PatchDocuments(ctx context.Context, engineName string, documents interface{}) (res []UpdateResponse, err error)
// Update (replace) a list of documents
// Every document is processed separately.
// Documents without ID will have auto-generated ID's.
// Non-existent documents will be automatically created.
UpdateDocuments(ctx context.Context, engineName string, documents interface{}) (res []UpdateResponse, err error)
// Remove a list of documents specified as []string of ID's or []interface{} of documents with "id" field
// Every document is processed separately.
RemoveDocuments(ctx context.Context, engineName string, documentsOrIDs interface{}) (res []DeleteResponse, err error)
// List documents
ListDocuments(ctx context.Context, engineName string, page Page) (response DocumentResponse, err error)
// Search documents by query
SearchDocuments(ctx context.Context, engineName string, query Query) (response DocumentResponse, err error)
}
// EngineAPI engine api
type EngineAPI interface {
// List an engine by name
ListEngine(ctx context.Context, engineName string) (data EngineDescription, err error)
// List engines with pagination
ListEngines(ctx context.Context, page Page) (data EngineResponse, err error)
// List all available engines
ListAllEngines(ctx context.Context) (data []EngineDescription, err error)
// Create engine with name
CreateEngine(ctx context.Context, request CreateEngineRequest) (EngineDescription, error)
// Delete engine with name
DeleteEngine(ctx context.Context, engineName string) (err error)
// Create engine if doesn't exist.
// Optionally update a schema even if engine exists.
EnsureEngine(ctx context.Context, request CreateEngineRequest, schema ...schema.Definition) (err error)
}
// SchemaAPI schema api
type SchemaAPI interface {
// List a schema definition by engineName
ListSchema(ctx context.Context, engineName string) (data schema.Definition, err error)
// Update schema by engineName (create or change fields).
// Fields cannot be deleted.
UpdateSchema(ctx context.Context, engineName string, def schema.Definition) (err error)
}
// APIClient interface
type APIClient interface {
// Engine API
EngineAPI
// Schema API
SchemaAPI
// Document API
DocumentAPI
}