Documentation
¶
Overview ¶
Package api is the OpenArch REST client. The generated code is in package gen (run 'make generate' after a change to api/openapi.json).
Index ¶
- Variables
- func IsPath(ref string) bool
- type Client
- func (c *Client) Check(status int, what string) error
- func (c *Client) CreateDocument(ctx context.Context, parent string, body []byte) (Document, error)
- func (c *Client) DeleteDocument(ctx context.Context, id string) error
- func (c *Client) GetDocument(ctx context.Context, ref string) (Document, error)
- func (c *Client) Ping(ctx context.Context) (PingResult, error)
- func (c *Client) Query(ctx context.Context, o QueryOptions) (QueryResult, error)
- func (c *Client) Transport(err error, what string) error
- func (c *Client) URL() string
- type Document
- type PingResult
- type QueryOptions
- type QueryResult
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound is wrapped by the errors of calls that got HTTP 404.
Functions ¶
Types ¶
type Client ¶
type Client struct {
Gen *gen.ClientWithResponses
// contains filtered or unexported fields
}
Client calls the OpenArch API with one set of credentials.
func New ¶
New returns a client. log receives one debug line per request and response, with the Authorization header redacted.
func (*Client) Check ¶
Check maps an HTTP status to a CLI error. 401 and 403 are authentication errors (exit code 6); other non-2xx statuses are remote errors (exit code 5).
func (*Client) CreateDocument ¶
CreateDocument creates a document under a parent given by id or path. body is a JSON object.
func (*Client) DeleteDocument ¶
DeleteDocument deletes a document by id.
func (*Client) GetDocument ¶
GetDocument returns a document by id, or by path when ref starts with "/".
func (*Client) Ping ¶
func (c *Client) Ping(ctx context.Context) (PingResult, error)
Ping reads the server version and checks the credentials with an authenticated call.
func (*Client) Query ¶
func (c *Client) Query(ctx context.Context, o QueryOptions) (QueryResult, error)
Query runs a query (POST /api/query).
type Document ¶
type Document struct {
Raw json.RawMessage
// contains filtered or unexported fields
}
Document is a document as returned by OpenArch. It is kept as raw JSON, so that no property is lost, with the fields the CLI shows in text mode decoded.
func (Document) MarshalJSON ¶
MarshalJSON writes the document exactly as OpenArch returned it.
type PingResult ¶
type PingResult struct {
URL string `json:"url"`
User string `json:"user"`
Version string `json:"version,omitempty"`
Authenticated bool `json:"authenticated"`
Sources auth.Sources `json:"sources"`
Workspace string `json:"workspace,omitempty"`
}
PingResult is the outcome of Ping.
type QueryOptions ¶
type QueryOptions struct {
Query string
Syntax string // "" (hxql) or "expr"
Limit int64
Offset int64
Sort []string
// Sync waits until the full-text index has the latest changes.
Sync bool
// Total asks the server to count every match.
Total bool
}
QueryOptions are the inputs of Query.
type QueryResult ¶
type QueryResult struct {
Raw json.RawMessage
Documents []Document
Count int64
TotalCount int64
Offset int64
Truncated bool
}
QueryResult is the result of a query, kept as raw JSON with the documents decoded.
func (QueryResult) MarshalJSON ¶
func (r QueryResult) MarshalJSON() ([]byte, error)
MarshalJSON writes the result exactly as OpenArch returned it.