platformapi

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const PlatformAuthRequiredMessage = "" /* 234-byte string literal not displayed */

PlatformAuthRequiredMessage tells users how to use the platform-backed CLI path.

Variables

This section is empty.

Functions

func AuthRequiredError

func AuthRequiredError(err error) error

AuthRequiredError wraps platform credential errors with user-facing mode guidance.

func HasPlatformClient

func HasPlatformClient() bool

func NormalizeBaseURL

func NormalizeBaseURL(raw string) string

NormalizeBaseURL trims whitespace, trailing slashes, and an optional trailing /api suffix from a platform base URL.

Types

type AdapterCertificate

type AdapterCertificate struct {
	Certificate string    `json:"certificate"`
	CABundle    string    `json:"caBundle"`
	SPIFFEID    string    `json:"spiffeID"`
	ExpiresAt   time.Time `json:"expiresAt"`
}

type AdapterCertificateRequest

type AdapterCertificateRequest struct {
	Namespace string `json:"namespace"`
	Session   string `json:"session"`
	CSR       string `json:"csr"`
}

type AdapterSession

type AdapterSession struct {
	Name           string    `json:"name"`
	Namespace      string    `json:"namespace"`
	HumanID        string    `json:"humanID"`
	AgentID        string    `json:"agentID"`
	TeamID         string    `json:"teamID,omitempty"`
	ServerName     string    `json:"serverName"`
	ConsentedTrust string    `json:"consentedTrust"`
	PolicyVersion  string    `json:"policyVersion"`
	ExpiresAt      time.Time `json:"expiresAt"`
	Reused         bool      `json:"reused"`
	TrustDomain    string    `json:"trustDomain,omitempty"`
}

AdapterSession captures the identity the adapter must inject into runtime requests. ExpiresAt is absolute (server-side time); callers should refresh before it elapses.

type AdapterSessionRequest

type AdapterSessionRequest struct {
	ServerName     string `json:"serverName"`
	Namespace      string `json:"namespace,omitempty"`
	AgentID        string `json:"agentID"`
	RequestedTrust string `json:"requestedTrust,omitempty"`
	RequestedTTL   string `json:"requestedTTL,omitempty"`
}

AdapterSessionRequest is the input contract for the platform API endpoint POST /api/v1/runtime/adapter/sessions. RequestedTTL/Trust are optional; empty values fall back to platform-side defaults.

type Agent

type Agent struct {
	ID        string `json:"id"`
	TeamID    string `json:"team_id"`
	TeamSlug  string `json:"team_slug"`
	Name      string `json:"name"`
	Status    string `json:"status"`
	CreatedAt string `json:"created_at,omitempty"`
	UpdatedAt string `json:"updated_at,omitempty"`
}

type AgentPage

type AgentPage struct {
	Agents     []Agent `json:"agents"`
	NextCursor string  `json:"next_cursor,omitempty"`
}

type ImagePublishRecord

type ImagePublishRecord struct {
	ImageRef    string `json:"image_ref"`
	SourceImage string `json:"source_image,omitempty"`
	Mode        string `json:"mode,omitempty"`
}

type PlatformClient

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

PlatformClient calls the platform API with an API key.

func NewPlatformClient

func NewPlatformClient() (*PlatformClient, error)

NewPlatformClient returns a client when platform credentials and API base URL are configured. If the user is not logged in, returns authfile.ErrNotFound.

func ResolvePlatformOrKube

func ResolvePlatformOrKube(useKube bool) (*PlatformClient, bool, error)

ResolvePlatformOrKube returns direct Kubernetes mode only when useKube is explicit. Otherwise it requires platform API credentials and does not fall back to kubeconfig.

func (*PlatformClient) ApplyAccessFromYAMLFile

func (c *PlatformClient) ApplyAccessFromYAMLFile(ctx context.Context, path string) error

func (*PlatformClient) ApplyRuntimeServer

func (c *PlatformClient) ApplyRuntimeServer(ctx context.Context, name, namespace string, spec mcpv1alpha1.MCPServerSpec) (ServerListItem, error)

func (*PlatformClient) ApplyRuntimeServerWithScope

func (c *PlatformClient) ApplyRuntimeServerWithScope(ctx context.Context, name, namespace, scope string, spec mcpv1alpha1.MCPServerSpec) (ServerListItem, error)

func (*PlatformClient) ApplyRuntimeServerWithScopeUpdate

func (c *PlatformClient) ApplyRuntimeServerWithScopeUpdate(ctx context.Context, name, namespace, scope string, spec mcpv1alpha1.MCPServerSpec, update bool) (ServerListItem, error)

func (*PlatformClient) CreateAdapterSession

func (c *PlatformClient) CreateAdapterSession(ctx context.Context, req AdapterSessionRequest) (AdapterSession, error)

CreateAdapterSession asks the platform to issue (or reuse) an MCPAgentSession for the calling principal. The returned session.Name doubles as the SessionID the adapter forwards on every runtime request.

func (*PlatformClient) CreateAgent

func (c *PlatformClient) CreateAgent(ctx context.Context, teamSlug, name string) (Agent, error)

func (*PlatformClient) CreateTeam

func (c *PlatformClient) CreateTeam(ctx context.Context, slug, name string) (Team, error)

func (*PlatformClient) CreateTeamUser

func (c *PlatformClient) CreateTeamUser(ctx context.Context, slug, email, password, role string) (TeamMembership, error)

func (*PlatformClient) CreateUser

func (c *PlatformClient) CreateUser(ctx context.Context, email, password, role string) (PlatformUser, error)

func (*PlatformClient) CurrentPrincipal

func (c *PlatformClient) CurrentPrincipal(ctx context.Context) (Principal, error)

func (*PlatformClient) DeleteGrant

func (c *PlatformClient) DeleteGrant(ctx context.Context, namespace, name string) error

func (*PlatformClient) DeleteRuntimeServer

func (c *PlatformClient) DeleteRuntimeServer(ctx context.Context, namespace, name string) error

func (*PlatformClient) DeleteSession

func (c *PlatformClient) DeleteSession(ctx context.Context, namespace, name string) error

func (*PlatformClient) GetAgent

func (c *PlatformClient) GetAgent(ctx context.Context, id string) (Agent, error)

func (*PlatformClient) GetGrant

func (c *PlatformClient) GetGrant(ctx context.Context, namespace, name string) (sentinelaccess.GrantSummary, error)

func (*PlatformClient) GetRuntimePolicy

func (c *PlatformClient) GetRuntimePolicy(ctx context.Context, namespace, server string) ([]byte, error)

func (*PlatformClient) GetSession

func (c *PlatformClient) GetSession(ctx context.Context, namespace, name string) (sentinelaccess.SessionSummary, error)

func (*PlatformClient) GetTeam

func (c *PlatformClient) GetTeam(ctx context.Context, slug string) (Team, error)

func (*PlatformClient) IssueAdapterCertificate

func (c *PlatformClient) IssueAdapterCertificate(ctx context.Context, req AdapterCertificateRequest) (AdapterCertificate, error)

func (*PlatformClient) ListAgents

func (c *PlatformClient) ListAgents(ctx context.Context, teamSlug, status, query, cursor string, limit int) (AgentPage, error)

func (*PlatformClient) ListGrants

func (c *PlatformClient) ListGrants(ctx context.Context, namespace string) ([]sentinelaccess.GrantSummary, error)

func (*PlatformClient) ListNamespaces

func (c *PlatformClient) ListNamespaces(ctx context.Context) ([]namespaceListItem, error)

func (*PlatformClient) ListRuntimeServers

func (c *PlatformClient) ListRuntimeServers(ctx context.Context, namespace string) ([]ServerListItem, error)

func (*PlatformClient) ListRuntimeTools

func (c *PlatformClient) ListRuntimeTools(ctx context.Context, filters map[string]string) ([]RuntimeToolRow, error)

func (*PlatformClient) ListSessions

func (c *PlatformClient) ListSessions(ctx context.Context, namespace string) ([]sentinelaccess.SessionSummary, error)

func (*PlatformClient) ListTeamMembers

func (c *PlatformClient) ListTeamMembers(ctx context.Context, slug string) ([]TeamMembership, error)

func (*PlatformClient) ListTeams

func (c *PlatformClient) ListTeams(ctx context.Context) ([]Team, error)

func (*PlatformClient) PatchGrant

func (c *PlatformClient) PatchGrant(ctx context.Context, namespace, name string, disabled bool) error

func (*PlatformClient) PatchSession

func (c *PlatformClient) PatchSession(ctx context.Context, namespace, name string, revoked bool) error

func (*PlatformClient) PushRegistryImage

func (c *PlatformClient) PushRegistryImage(ctx context.Context, tarPath, target, scope string) error

PushRegistryImage uploads a docker save tar and asks the platform API to push it to the configured registry from inside the cluster.

func (*PlatformClient) RecordImagePublish

func (c *PlatformClient) RecordImagePublish(ctx context.Context, record ImagePublishRecord) error

func (*PlatformClient) RenameAgent

func (c *PlatformClient) RenameAgent(ctx context.Context, id, name string) (Agent, error)

func (*PlatformClient) RevokeGrantSessions

func (c *PlatformClient) RevokeGrantSessions(ctx context.Context, namespace, name string) (int, error)

func (*PlatformClient) SetAgentActive

func (c *PlatformClient) SetAgentActive(ctx context.Context, id string, active bool) (Agent, error)

func (*PlatformClient) UpsertTeamMember

func (c *PlatformClient) UpsertTeamMember(ctx context.Context, slug, userID, role string) (TeamMembership, error)

func (*PlatformClient) ValidateCredentials

func (c *PlatformClient) ValidateCredentials(ctx context.Context) error

type PlatformUser

type PlatformUser struct {
	ID        string `json:"id"`
	Email     string `json:"email"`
	Role      string `json:"role"`
	Namespace string `json:"namespace,omitempty"`
}

type Principal

type Principal struct {
	Role              string   `json:"role"`
	Subject           string   `json:"subject,omitempty"`
	Email             string   `json:"email,omitempty"`
	Namespace         string   `json:"namespace,omitempty"`
	AllowedNamespaces []string `json:"allowedNamespaces,omitempty"`
	Teams             []Team   `json:"teams,omitempty"`
}

type RuntimeToolRow

type RuntimeToolRow struct {
	ToolName      string            `json:"tool_name"`
	Description   string            `json:"description,omitempty"`
	ServerName    string            `json:"server_name"`
	Namespace     string            `json:"namespace"`
	TeamID        string            `json:"team_id,omitempty"`
	EndpointURL   string            `json:"endpoint_url,omitempty"`
	Declared      bool              `json:"declared"`
	Live          bool              `json:"live"`
	DriftStatus   string            `json:"drift_status"`
	RequiredTrust string            `json:"required_trust,omitempty"`
	SideEffect    string            `json:"side_effect,omitempty"`
	RiskLevel     string            `json:"risk_level,omitempty"`
	Labels        map[string]string `json:"labels,omitempty"`
	ConnectConfig map[string]any    `json:"connect_config,omitempty"`
}

type ServerListItem

type ServerListItem struct {
	Name        string            `json:"name"`
	Namespace   string            `json:"namespace"`
	TeamID      string            `json:"team_id,omitempty"`
	Image       string            `json:"image,omitempty"`
	ImageTag    string            `json:"imageTag,omitempty"`
	Description string            `json:"description,omitempty"`
	Ready       string            `json:"ready"`
	Status      string            `json:"status"`
	Labels      map[string]string `json:"labels"`
	Age         string            `json:"age"`
	Endpoint    string            `json:"endpoint,omitempty"`
	Tools       []ToolConfig      `json:"tools,omitempty"`
	AccessJSON  map[string]any    `json:"access_json,omitempty"`
}

ServerListItem is one row from the platform API runtime servers list.

type Team

type Team struct {
	ID        string    `json:"id"`
	Slug      string    `json:"slug"`
	Name      string    `json:"name"`
	Namespace string    `json:"namespace"`
	CreatedAt time.Time `json:"created_at"`
}

type TeamMembership

type TeamMembership = platform.TeamMembership

type ToolConfig

type ToolConfig struct {
	Name          string            `json:"name"`
	Description   string            `json:"description,omitempty"`
	RequiredTrust string            `json:"requiredTrust,omitempty"`
	SideEffect    string            `json:"sideEffect,omitempty"`
	RiskLevel     string            `json:"riskLevel,omitempty"`
	Labels        map[string]string `json:"labels,omitempty"`
}

Jump to

Keyboard shortcuts

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