platformapi

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: None detected not legal advice Imports: 0 Imported by: 0

Documentation

Overview

Package platformapi is runtime-api's network client for platform-api. The two services share a network contract, platform-api's openapi.yaml, and not code: contract_test.go fails when this client calls an operation the spec omits.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAccessIntentDisabled is returned when platform-api's access intent journal is disabled (503).
	ErrAccessIntentDisabled = errors.New("access intent journal disabled")
	// ErrAccessIntentNotFound is returned when an access intent resource does not exist (404).
	ErrAccessIntentNotFound = errors.New("access intent not found")
	// ErrAccessIntentConflict is returned on stale fence/revision/observer epoch or revoked authority (409).
	ErrAccessIntentConflict = errors.New("access intent conflict")
	// ErrAccessIntentInvalid is returned on malformed requests (400).
	ErrAccessIntentInvalid = errors.New("invalid access intent request")
)
View Source
var (
	ErrAgentNotFound    = errors.New("agent not found")
	ErrTeamNotFound     = errors.New("team not found")
	ErrAgentNameTaken   = errors.New("agent name already exists in team")
	ErrInvalidAgentName = errors.New("invalid agent name")
)
View Source
var (
	// ErrTeamIntentDisabled is returned when PLATFORM_TEAM_INTENT_JOURNAL is off.
	ErrTeamIntentDisabled = errors.New("team intent journal disabled")
	// ErrTeamIntentConflict is returned when a receipt or observation is
	// rejected due to a stale fence, revision, observer epoch, or ownership mismatch.
	ErrTeamIntentConflict = errors.New("team intent conflict")
)
View Source
var (
	// ErrWorkloadIntentDisabled indicates PLATFORM_WORKLOAD_INTENT_JOURNAL is disabled.
	ErrWorkloadIntentDisabled = errors.New("workload intent journal disabled")
	// ErrWorkloadIntentNotFound indicates the requested workload intent does not exist.
	ErrWorkloadIntentNotFound = errors.New("workload intent not found")
	// ErrWorkloadIntentConflict indicates a stale fence, revision, observer epoch,
	// state transition, or mutable-tag overlap conflict (HTTP 409).
	ErrWorkloadIntentConflict = errors.New("workload intent conflict")
)
View Source
var ErrNotConfigured = errors.New("platform identity client not configured")

ErrNotConfigured is returned when platform identity is unavailable.

Functions

func IsSessionNotFound

func IsSessionNotFound(err error) bool

IsSessionNotFound accepts the shared sentinel and typed HTTP errors.

Types

type APIKeySummary

type APIKeySummary struct {
	ID        string     `json:"id"`
	Name      string     `json:"name"`
	Prefix    string     `json:"prefix"`
	CreatedAt time.Time  `json:"created_at"`
	Revoked   bool       `json:"revoked"`
	RevokedAt *time.Time `json:"revoked_at,omitempty"`
}

APIKeySummary is the non-secret metadata for a user API key.

type Agent

type Agent = apikit.Agent

type AgentPage

type AgentPage = apikit.AgentPage

type AuditEvent

type AuditEvent = apikit.AuditEvent

AuditEvent is the write-side platform audit envelope.

type AuditLog

type AuditLog struct {
	ID               int64     `json:"id"`
	UserID           string    `json:"user_id,omitempty"`
	Email            string    `json:"email,omitempty"`
	Action           string    `json:"action"`
	Resource         string    `json:"resource"`
	Namespace        string    `json:"namespace,omitempty"`
	Status           string    `json:"status"`
	Message          string    `json:"message,omitempty"`
	ActorIP          string    `json:"actor_ip,omitempty"`
	RequestID        string    `json:"request_id,omitempty"`
	Source           string    `json:"source,omitempty"`
	AuthIdentity     string    `json:"auth_identity,omitempty"`
	ImageRef         string    `json:"image_ref,omitempty"`
	ServerName       string    `json:"server_name,omitempty"`
	DeploymentTarget string    `json:"deployment_target,omitempty"`
	AgentID          string    `json:"agent_id,omitempty"`
	TeamID           string    `json:"team_id,omitempty"`
	TraceID          string    `json:"trace_id,omitempty"`
	CreatedAt        time.Time `json:"created_at"`
}

AuditLog is the read-side platform audit record.

type Client

type Client struct {
	BaseURL string
	Token   string
	HTTP    *http.Client
}

Client calls platform-api's /internal endpoints with the service token.

func (*Client) AbortImagePublication

func (c *Client) AbortImagePublication(ctx context.Context, publicationID string, req apikit.ImagePublicationAbortRequest) (apikit.ImagePublicationIntent, error)

func (*Client) ActivateEnrollmentIntent

func (c *Client) ActivateEnrollmentIntent(ctx context.Context, opID string, req apikit.EnrollmentIntentActivateRequest) (apikit.EnrollmentIntent, error)

func (*Client) AgentCertificates

func (c *Client) AgentCertificates(ctx context.Context, id, humanID string) (apikit.CertificateActivity, error)

func (*Client) ClaimAccessIntentObserverLease

func (c *Client) ClaimAccessIntentObserverLease(ctx context.Context, clusterKey, observerID string) (apikit.AccessIntentObserverLeaseResponse, error)

func (*Client) ClaimAgentCleanupIntentFence

func (c *Client) ClaimAgentCleanupIntentFence(ctx context.Context, agentID, workerID string) (apikit.AgentCleanupFenceResponse, error)

func (*Client) ClaimDeploymentIntentFence

func (c *Client) ClaimDeploymentIntentFence(ctx context.Context, deploymentID, workerID string) (apikit.DeploymentIntentFenceResponse, error)

func (*Client) ClaimEnrollmentIntentFence

func (c *Client) ClaimEnrollmentIntentFence(ctx context.Context, opID, workerID string) (apikit.EnrollmentIntentFenceResponse, error)

func (*Client) ClaimGrantIntentFence

func (c *Client) ClaimGrantIntentFence(ctx context.Context, grantID, workerID string) (apikit.GrantIntentFenceResponse, error)

func (*Client) ClaimImagePublicationFence

func (c *Client) ClaimImagePublicationFence(ctx context.Context, publicationID, workerID string) (apikit.ImagePublicationFenceResponse, error)

func (*Client) ClaimRestartOperationFence

func (c *Client) ClaimRestartOperationFence(ctx context.Context, operationID, workerID string) (apikit.RestartOperationFenceResponse, error)

func (*Client) ClaimServerIntentFence

func (c *Client) ClaimServerIntentFence(ctx context.Context, serverID, workerID string) (apikit.ServerIntentFenceResponse, error)

func (*Client) ClaimTeamIntentFence

func (c *Client) ClaimTeamIntentFence(ctx context.Context, teamID, workerID string) (apikit.TeamIntentFenceResponse, error)

func (*Client) ClaimTeamIntentObserverLease

func (c *Client) ClaimTeamIntentObserverLease(ctx context.Context, clusterKey, observerID string) (apikit.TeamIntentObserverLeaseResponse, error)

func (*Client) ClaimWorkloadObserverLease

func (c *Client) ClaimWorkloadObserverLease(ctx context.Context, clusterKey, observerID string) (apikit.WorkloadObserverLeaseResponse, error)

func (*Client) CompleteSessionEnrollment

func (c *Client) CompleteSessionEnrollment(ctx context.Context, namespace, name, uid string) error

func (*Client) Configured

func (c *Client) Configured() bool

Configured reports whether the client can reach platform-api.

func (*Client) CreateAgent

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

func (*Client) CreateEnrollmentIntent

func (c *Client) CreateEnrollmentIntent(ctx context.Context, req apikit.EnrollmentIntentCreateRequest) (apikit.EnrollmentIntent, error)

func (*Client) CreatePasswordUser

func (c *Client) CreatePasswordUser(ctx context.Context, email, password, role string) (User, error)

func (*Client) CreateTeam

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

func (*Client) CreateTeamUser

func (c *Client) CreateTeamUser(ctx context.Context, teamSlug, email, password, role string) (User, TeamMembership, error)

func (*Client) DeleteDeploymentIntent

func (c *Client) DeleteDeploymentIntent(ctx context.Context, deploymentID string, req apikit.DeploymentIntentDeleteRequest) (apikit.DeploymentIntent, error)

func (*Client) DeletePendingSession

func (c *Client) DeletePendingSession(ctx context.Context, namespace, name, uid, humanID string) error

func (*Client) DeleteSession

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

func (*Client) DeleteSessionIfUID

func (c *Client) DeleteSessionIfUID(ctx context.Context, namespace, name, uid string) error

func (*Client) DeleteTeamBySlug

func (c *Client) DeleteTeamBySlug(ctx context.Context, slug string) error

func (*Client) DeleteTeamMembership

func (c *Client) DeleteTeamMembership(ctx context.Context, teamSlug, userID string) error

func (*Client) FinalizeImagePublication

func (c *Client) FinalizeImagePublication(ctx context.Context, publicationID string, req apikit.ImagePublicationFinalizeRequest) (apikit.ImagePublicationIntent, error)

func (*Client) GetAgent

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

func (*Client) GetAgentCleanupIntent

func (c *Client) GetAgentCleanupIntent(ctx context.Context, agentID string) (apikit.AgentCleanupIntent, bool, error)

func (*Client) GetDeploymentIntent

func (c *Client) GetDeploymentIntent(ctx context.Context, deploymentID string) (apikit.DeploymentIntent, bool, error)

func (*Client) GetEnrollmentIntent

func (c *Client) GetEnrollmentIntent(ctx context.Context, opID string) (apikit.EnrollmentIntent, bool, error)

func (*Client) GetGrantIntent

func (c *Client) GetGrantIntent(ctx context.Context, grantID string) (apikit.GrantIntent, bool, error)

func (*Client) GetImagePublicationIntent

func (c *Client) GetImagePublicationIntent(ctx context.Context, publicationID string) (apikit.ImagePublicationIntent, bool, error)

func (*Client) GetNamespace

func (c *Client) GetNamespace(ctx context.Context, namespace string) (map[string]any, bool, error)

func (*Client) GetRestartOperationIntent

func (c *Client) GetRestartOperationIntent(ctx context.Context, operationID string) (apikit.RestartOperationIntent, bool, error)

func (*Client) GetServerIntent

func (c *Client) GetServerIntent(ctx context.Context, serverID string) (apikit.ServerIntent, bool, error)

func (*Client) GetSession

func (c *Client) GetSession(ctx context.Context, namespace, name string) (sessionstate.Session, bool, error)

func (*Client) GetTeamBySlug

func (c *Client) GetTeamBySlug(ctx context.Context, slug string) (Team, bool, error)

func (*Client) GetTeamIntent

func (c *Client) GetTeamIntent(ctx context.Context, teamID string) (apikit.TeamNamespaceIntent, bool, error)

func (*Client) ListAgents

func (c *Client) ListAgents(ctx context.Context, teamSlug, statusFilter, q, cursor string, limit int) (AgentPage, error)

func (*Client) ListDeploymentIntents

func (c *Client) ListDeploymentIntents(ctx context.Context) ([]apikit.DeploymentIntent, error)

func (*Client) ListEnrollmentIntents

func (c *Client) ListEnrollmentIntents(ctx context.Context) ([]apikit.EnrollmentIntent, error)

func (*Client) ListGrantIntents

func (c *Client) ListGrantIntents(ctx context.Context) ([]apikit.GrantIntent, error)

func (*Client) ListImagePublicationIntents

func (c *Client) ListImagePublicationIntents(ctx context.Context) ([]apikit.ImagePublicationIntent, error)

func (*Client) ListNamespaces

func (c *Client) ListNamespaces(ctx context.Context) ([]map[string]any, error)

func (*Client) ListRestartOperationIntents

func (c *Client) ListRestartOperationIntents(ctx context.Context) ([]apikit.RestartOperationIntent, error)

func (*Client) ListServerIntents

func (c *Client) ListServerIntents(ctx context.Context) ([]apikit.ServerIntent, error)

func (*Client) ListSessions

func (c *Client) ListSessions(ctx context.Context, namespace string) ([]sessionstate.Session, error)

ListSessions drains bounded pages. Management callers retain the existing list contract; the gateway snapshot uses its separate authenticated audience.

func (*Client) ListSessionsFiltered

func (c *Client) ListSessionsFiltered(ctx context.Context, filter sessionstate.Filter) ([]sessionstate.Session, error)

func (*Client) ListTeamIntents

func (c *Client) ListTeamIntents(ctx context.Context) ([]apikit.TeamNamespaceIntent, error)

func (*Client) ListTeamMemberships

func (c *Client) ListTeamMemberships(ctx context.Context, teamSlug string) ([]TeamMembership, error)

func (*Client) ListTeams

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

func (*Client) OperationsSnapshot

func (c *Client) OperationsSnapshot(ctx context.Context, filter OperationsFilter) (OperationsSnapshot, error)

OperationsSnapshot loads user, audit, and image activity for admin operations.

func (*Client) OverviewCounts

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

func (*Client) PrincipalForUserID

func (c *Client) PrincipalForUserID(ctx context.Context, userID string) (passport.Principal, error)

func (*Client) PutSession

func (c *Client) PutSession(ctx context.Context, item sessionstate.Session) (sessionstate.Session, error)

func (*Client) RecordAgentCleanupIntentReceipt

func (c *Client) RecordAgentCleanupIntentReceipt(ctx context.Context, agentID string, req apikit.AgentCleanupReceiptRequest) (apikit.AgentCleanupReceipt, error)

func (*Client) RecordDeploymentIntentObservation

func (c *Client) RecordDeploymentIntentObservation(ctx context.Context, deploymentID string, req apikit.DeploymentIntentObservationRequest) (apikit.WorkloadStatusObservation, error)

func (*Client) RecordDeploymentIntentReceipt

func (c *Client) RecordDeploymentIntentReceipt(ctx context.Context, deploymentID string, req apikit.DeploymentIntentReceiptRequest) (apikit.WorkloadExecutionReceipt, error)

func (*Client) RecordEnrollmentIntentReceipt

func (c *Client) RecordEnrollmentIntentReceipt(ctx context.Context, opID string, req apikit.EnrollmentIntentReceiptRequest) (apikit.EnrollmentReceipt, error)

func (*Client) RecordGrantIntentObservation

func (c *Client) RecordGrantIntentObservation(ctx context.Context, grantID string, req apikit.GrantIntentObservationRequest) (apikit.GrantObservation, error)

func (*Client) RecordGrantIntentReceipt

func (c *Client) RecordGrantIntentReceipt(ctx context.Context, grantID string, req apikit.GrantIntentReceiptRequest) (apikit.GrantReceipt, error)

func (*Client) RecordImagePublicationReceipt

func (c *Client) RecordImagePublicationReceipt(ctx context.Context, publicationID string, req apikit.ImagePublicationReceiptRequest) (apikit.WorkloadExecutionReceipt, error)

func (*Client) RecordRestartComponentCheckpoint

func (c *Client) RecordRestartComponentCheckpoint(ctx context.Context, operationID string, req apikit.RestartComponentCheckpointRequest) (apikit.RestartOperationIntent, error)

func (*Client) RecordRestartOperationReceipt

func (c *Client) RecordRestartOperationReceipt(ctx context.Context, operationID string, req apikit.RestartOperationReceiptRequest) (apikit.WorkloadExecutionReceipt, error)

func (*Client) RecordServerIntentObservation

func (c *Client) RecordServerIntentObservation(ctx context.Context, serverID string, req apikit.ServerIntentObservationRequest) (apikit.WorkloadStatusObservation, error)

func (*Client) RecordServerIntentReceipt

func (c *Client) RecordServerIntentReceipt(ctx context.Context, serverID string, req apikit.ServerIntentReceiptRequest) (apikit.WorkloadExecutionReceipt, error)

func (*Client) RecordServerRetirementCheckpoint

func (c *Client) RecordServerRetirementCheckpoint(ctx context.Context, serverID string, req apikit.ServerRetirementCheckpointRequest) (apikit.ServerIntent, error)

func (*Client) RecordTeamIntentObservation

func (c *Client) RecordTeamIntentObservation(ctx context.Context, teamID string, req apikit.TeamIntentObservationRequest) (apikit.TeamNamespaceObservation, error)

func (*Client) RecordTeamIntentReceipt

func (c *Client) RecordTeamIntentReceipt(ctx context.Context, teamID string, req apikit.TeamIntentReceiptRequest) (apikit.TeamNamespaceReceipt, error)

func (*Client) RenameAgent

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

func (*Client) RetireServerIntent

func (c *Client) RetireServerIntent(ctx context.Context, serverID string, req apikit.ServerIntentRetireRequest) (apikit.ServerIntent, error)

func (*Client) RevokeGrantIntent

func (c *Client) RevokeGrantIntent(ctx context.Context, grantID string, deleteGrant bool) (apikit.GrantIntent, error)

func (*Client) RevokeSession

func (c *Client) RevokeSession(ctx context.Context, namespace, name, cause string) error

func (*Client) RevokeSessions

func (c *Client) RevokeSessions(ctx context.Context, filter sessionstate.Filter, cause string) (int64, error)

func (*Client) SetAgentStatus

func (c *Client) SetAgentStatus(ctx context.Context, id, statusName, actorID string) (Agent, error)

func (*Client) SetSessionRevoked

func (c *Client) SetSessionRevoked(ctx context.Context, namespace, name string, revoked bool, cause string) error

func (*Client) UpsertDeploymentIntent

func (c *Client) UpsertDeploymentIntent(ctx context.Context, req apikit.DeploymentIntentUpsertRequest) (apikit.DeploymentIntent, error)

func (*Client) UpsertGrantIntent

func (c *Client) UpsertGrantIntent(ctx context.Context, req apikit.GrantIntentUpsertRequest) (apikit.GrantIntent, error)

func (*Client) UpsertServerIntent

func (c *Client) UpsertServerIntent(ctx context.Context, req apikit.ServerIntentUpsertRequest) (apikit.ServerIntent, error)

func (*Client) UpsertTeamMembership

func (c *Client) UpsertTeamMembership(ctx context.Context, teamSlug, userID, role string) (TeamMembership, error)

func (*Client) WriteAudit

func (c *Client) WriteAudit(ctx context.Context, event AuditEvent)

WriteAudit posts an audit event to platform-api.

type ImageActivity

type ImageActivity struct {
	UserID           string    `json:"user_id,omitempty"`
	Email            string    `json:"email,omitempty"`
	Namespace        string    `json:"namespace,omitempty"`
	ImageRef         string    `json:"image_ref"`
	SourceImage      string    `json:"source_image,omitempty"`
	ServerName       string    `json:"server_name,omitempty"`
	DeploymentTarget string    `json:"deployment_target,omitempty"`
	Action           string    `json:"action"`
	Status           string    `json:"status"`
	Source           string    `json:"source,omitempty"`
	CreatedAt        time.Time `json:"created_at"`
}

ImageActivity describes image publish or deploy-related audit entries.

type OperationsFilter

type OperationsFilter struct {
	User       string
	UserSearch string
	TraceID    string
	Since      time.Time
	Until      time.Time
	Limit      int
}

OperationsFilter constrains platform operations and activity queries.

type OperationsFilterResponse

type OperationsFilterResponse struct {
	User  string `json:"user,omitempty"`
	Since string `json:"since,omitempty"`
	Until string `json:"until,omitempty"`
	Limit int    `json:"limit"`
}

OperationsFilterResponse is the API echo of an operations filter.

type OperationsSnapshot

type OperationsSnapshot struct {
	Users     []UserActivity  `json:"users"`
	AuditLogs []AuditLog      `json:"audit_logs"`
	Images    []ImageActivity `json:"images"`
}

OperationsSnapshot is the platform activity bundle for admin operations.

type Team

type Team = apikit.Team

Team is a managed platform team and its Kubernetes namespace.

type TeamMembership

type TeamMembership = apikit.TeamMembership

TeamMembership is the platform team membership API contract.

type User

type User = apikit.User

User is a platform user record returned by identity APIs.

type UserActivity

type UserActivity struct {
	ID                  string     `json:"id"`
	Email               string     `json:"email"`
	Role                string     `json:"role"`
	Namespace           string     `json:"namespace,omitempty"`
	CreatedAt           time.Time  `json:"created_at"`
	LastLoginAt         *time.Time `json:"last_login_at,omitempty"`
	LastActivityAt      *time.Time `json:"last_activity_at,omitempty"`
	LoginCount          int64      `json:"login_count"`
	FailedActionCount   int64      `json:"failed_action_count"`
	RegistryCredentials int64      `json:"registry_credentials"`
	APIKeys             int64      `json:"api_keys"`
}

UserActivity summarizes recent platform activity for a user account.

Jump to

Keyboard shortcuts

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