Documentation
¶
Overview ¶
Package cli is the cobra command surface for the `iam` administrative CLI. main.go is a thin wrapper around Execute(); external consumers (e.g. liquidityio/cli's `liquid iam ...`) can import the package and mount NewRootCmd() under their own root command via cobra.AddCommand.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Version = "(dev)"
Version is overridden at link time by -ldflags "-X .../cli.Version=...". Falls back to "(dev)" when built without flags.
Functions ¶
func Execute ¶
func Execute() error
Execute runs the root command. main() calls this; library consumers usually want NewRootCmd() instead.
func NewRootCmd ¶
NewRootCmd returns a fresh root command containing the entire `iam` surface. Each call returns a new tree so it's safe to mount under a different parent without worrying about cobra's global state.
Usage from an external Go consumer:
import iamcli "github.com/hanzoai/iam/cmd/iam/cli"
root := &cobra.Command{Use: "liquid"}
root.AddCommand(iamcli.NewRootCmd()) // mounts the whole tree
// — or to remount under a different name:
iam := iamcli.NewRootCmd()
iam.Use = "iam" // already "iam", but you can rename here
root.AddCommand(iam)
All subcommands honour --addr and --token; the persistent flags declared here are inherited by every leaf.
Types ¶
type APIError ¶
APIError is the error returned when IAM responds with a non-2xx, or when its status="error" envelope flags a logical failure. Mirrors the TypeScript HanzoAPIError shape used by @hanzo/sdk so callers can pattern- match on Status (HTTP) and Message (server msg) the same way.
type Application ¶
type Application struct {
Owner string `json:"owner"`
Name string `json:"name"`
Organization string `json:"organization"`
DisplayName string `json:"displayName"`
ClientId string `json:"clientId"`
ClientSecret string `json:"clientSecret,omitempty"`
GrantTypes []string `json:"grantTypes,omitempty"`
RedirectUris []string `json:"redirectUris"`
}
Application is a minimal projection of object.Application — only the fields the CLI prints / round-trips. Decode is permissive: extra fields in the JSON are preserved when we feed a raw upsert body back to the server (see appUpsert), but the projection here keeps the CLI independent of every new column added to the server-side row.
type Config ¶
Config carries the IAM server address + bearer token resolved from the environment and/or top-level flags. One instance is built in cli.go and shared by every subcommand.
func (*Config) RequireToken ¶
RequireToken returns an error pointing the operator at how to find a service token if IAM_TOKEN is unset. Every authenticated subcommand calls this before issuing a request.
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient wraps a *http.Client with the IAM-specific Bearer token, envelope handling, and URL builder.
func NewHTTPClient ¶
func NewHTTPClient(cfg *Config) *HTTPClient
func (*HTTPClient) Addr ¶
func (h *HTTPClient) Addr() string
func (*HTTPClient) Get ¶
Get issues a GET, unwraps the IAM envelope, and decodes data into out. Pass out=nil to discard the body.
type Organization ¶
type Organization struct {
Owner string `json:"owner"`
Name string `json:"name"`
DisplayName string `json:"displayName"`
WebsiteUrl string `json:"websiteUrl"`
}
Organization is the CLI projection of object.Organization.
type User ¶
type User struct {
Owner string `json:"owner"`
Name string `json:"name"`
DisplayName string `json:"displayName"`
Email string `json:"email"`
Phone string `json:"phone"`
IsAdmin bool `json:"isAdmin"`
Type string `json:"type"`
}
User is the CLI projection of object.User — enough to print a useful table and let the operator confirm a row exists. Anything richer should go through the JSON path (`--json` or `user get`).