api

package
v0.32.1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Overview

Package api assembles and runs the `jentic` command tree — the API-spec surface (register/identity, context/env, catalog, apis, search, inspect, execute) for discovering, inspecting, and executing against the Jentic API catalog. Data-plane commands speak to the control plane through the generated SDK (client/generated/control); `jentic migrate` is the sole reader of the legacy V1 store (see legacy_store.go).

Index

Constants

View Source
const PositionalArg = "<arg>"

PositionalArg is the CuratedBinding.Bind value for a spec field satisfied by a positional argument rather than a flag.

Variables

This section is empty.

Functions

func ExecuteAPI

func ExecuteAPI()

ExecuteAPI runs the jentic (API-spec) command tree and exits with an appropriate status code.

func NewDocsRoot

func NewDocsRoot() *cobra.Command

NewDocsRoot builds the assembled `jentic` root with a throwaway App for documentation generation. No filesystem or network access happens at construction time — commands only act when run — so a zero App is safe.

func TreeBuilder

func TreeBuilder() core.TreeBuilder

TreeBuilder exposes the built-in `jentic` (API) command tree as a core.TreeBuilder so a downstream module can compose it via core.NewRootCmd(deps, api.TreeBuilder()). cli/pkg/clitree re-exports it so other modules can import it (internal/ is not importable cross-module).

Types

type CuratedBinding

type CuratedBinding struct {
	// Command is the space-separated path under the `jentic` root, e.g.
	// "history export".
	Command string
	// Params is the zero value of the generated request params/body struct the
	// command constructs.
	Params any
	// Bind maps a json field name to the flag that populates it (or
	// PositionalArg when a positional argument does).
	Bind map[string]string
	// NotExposed maps a json field name to the one-line reviewed reason it has
	// no flag. `jentic api <op>` still reaches every one of these.
	NotExposed map[string]string
}

CuratedBinding declares, for ONE curated command, how the exported fields of its generated request params/body struct surface on the CLI. It is the registry Test1G_SpecFlagCoverageParity (impl/0.0 §1G) reflects over: every json field of Params must appear in exactly one of Bind or NotExposed, every Bind flag must exist on the command, and neither map may name a field the struct no longer has. The payoff: `make generate-api` after a spec addition makes 1G fail until a human classifies the new field — bind it or record why not — so a curated command can never silently lag its spec (GEN-1).

func CuratedBindings

func CuratedBindings() []CuratedBinding

CuratedBindings returns the registry of curated commands that construct generated request structs. Commands living entirely on internal/apiclient (search, apis list/show, execute) have no generated struct to drift from and are not listed; they migrate in here as they move onto the generated SDK.

type HTTPError

type HTTPError struct {
	StatusCode int
	Body       string
}

HTTPError is a non-2xx control-plane response. It mirrors the shape the hand-written httpx.HTTPError offered — StatusCode plus the raw problem-details body — so existing error-mapping logic ports unchanged. (Named HTTPError, not APIError, so it does not stutter as api.APIError — revive `exported`.)

func (*HTTPError) Detail

func (e *HTTPError) Detail() string

Detail extracts an RFC 9457 problem-details message, preferring the most specific key (matching the old httpx.HTTPError.Detail order exactly).

func (*HTTPError) Error

func (e *HTTPError) Error() string

func (*HTTPError) Fields

func (e *HTTPError) Fields() map[string]any

Fields decodes the problem-details body into a map so callers can read extension members. Returns an empty map when the body is not a JSON object.

Jump to

Keyboard shortcuts

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