api

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package api is a client for the NeuralTrust console's CLI API, /api/cli/v1: organizations, private TrustGate and TrustGuard instances, and the tokens an install needs. Responses carrying tokens are never logged.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client calls the CLI API of one console.

func New

func New(appURL string, hc *http.Client, t Tokens) *Client

New returns a client for the console at appURL.

func (*Client) Create

func (c *Client) Create(ctx context.Context, p Product, org, name string) (*Instance, error)

Create creates a private instance. A retry after a lost answer reuses the idempotency key, so the console returns the same instance.

func (*Client) Finalize

func (c *Client) Finalize(ctx context.Context, p Product, org, id, endpoint string) error

Finalize records where an installed instance is reachable.

func (*Client) InstallConfig

func (c *Client) InstallConfig(ctx context.Context, p Product, org, id string, rotate bool) (*InstallConfig, error)

InstallConfig issues credentials for an instance. With rotate, the credentials issued before stop working.

func (*Client) Instances

func (c *Client) Instances(ctx context.Context, p Product, org string) ([]Instance, error)

Instances lists an organization's private instances of a product.

func (*Client) Me

func (c *Client) Me(ctx context.Context) (*Me, error)

Me returns the signed-in user.

func (*Client) Orgs

func (c *Client) Orgs(ctx context.Context) ([]Org, error)

Orgs lists the user's organizations.

type Error

type Error struct {
	Status  int    `json:"-"`
	Code    string `json:"code"`
	Message string `json:"message"`
}

Error is an error answer from the console.

func (*Error) Error

func (e *Error) Error() string

type InstallConfig

type InstallConfig struct {
	TenantID        string `json:"tenantId"`
	ConfigSyncToken string `json:"configSyncToken"`
	EnrolmentToken  string `json:"enrolmentToken"`
	// ConfigSyncEndpoint and DataBridgeAddr are where the console's control
	// plane listens, host:port: the tokens are valid only there.
	ConfigSyncEndpoint string `json:"configSyncGrpcEndpoint,omitempty"`
	DataBridgeAddr     string `json:"databridgeAddr,omitempty"`
}

InstallConfig are the credentials an install of one instance needs.

func (InstallConfig) GoString

func (c InstallConfig) GoString() string

GoString keeps the tokens out of %#v.

func (InstallConfig) String

func (c InstallConfig) String() string

String keeps the tokens out of any formatted output.

type Instance

type Instance struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Region    string    `json:"region,omitempty"`
	Endpoint  string    `json:"endpoint,omitempty"`
	CreatedAt time.Time `json:"createdAt,omitzero"`
}

Instance is a private TrustGate or TrustGuard.

type Me

type Me struct {
	ID     string `json:"id"`
	Email  string `json:"email"`
	Region string `json:"region"`
	Org    *Org   `json:"org,omitempty"`
}

Me is the signed-in user, and the organization chosen at sign-in.

type Org

type Org struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	Region string `json:"region"`
	Role   string `json:"role"`
}

Org is an organization the user belongs to.

type Product

type Product string

Product is a product with private instances.

const (
	TrustGate  Product = "trustgate"
	TrustGuard Product = "trustguard"
)

The products the API manages instances of.

func (Product) Name

func (p Product) Name() string

Name is the product's display name.

type Tokens

type Tokens interface {
	Token(ctx context.Context) (string, error)
	Refresh(ctx context.Context) (string, error)
}

Tokens supplies the bearer token. Refresh is called once when the console answers 401.

Jump to

Keyboard shortcuts

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