Documentation
¶
Overview ¶
Package service builds the typed API client a command needs, the same way for every Norcube service: it resolves the profile, the target organization, the service endpoint, a token source for the service's audience (from the selected credential store) and the shared HTTP transport. Product command packages call New once per invocation instead of each wiring these by hand.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoOrganization = clierr.Usage(errors.New("no active organization. Run `norcube org use <slug>` or pass --org <slug>"))
ErrNoOrganization is returned when nothing names the organization to act in.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client[T any] struct { // API is the generated client. API T // Service is the registry entry the client talks to. Service registry.Service // Config is the resolved configuration of the selected profile. Config *config.Config // Flags are the invocation's global flags. Flags *clictx.Flags // Org is the organization the client acts in. Org api.Organization // Tokens mints the access tokens the client sends. Tokens *auth.TokenSource // Output is the requested output format. Output string }
Client is a typed API client plus the context it was built in.
type Constructor ¶
Constructor creates a generated client for a base URL that sends its requests through httpc and edit.
type Option ¶
type Option func(*options)
Option adjusts how New picks the organization.
func ForOrg ¶
ForOrg makes the client act in this organization, skipping --org and the profile (for commands that pick the organization themselves).
func WithOrgDefault ¶
func WithOrgDefault(fn func() (api.Organization, bool)) Option
WithOrgDefault supplies an organization that applies when neither --org nor NORCUBE_ORG is given, ahead of the profile's (a project file such as .langsync.json).