Help us shape the future of Go! Take the 2026 Go Developer Survey

api

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package api provides an API client for the TUI.

Package api provides types for the TUI API client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AMIBuildResponse

type AMIBuildResponse struct {
	ID           string    `json:"id"`
	TemplateName string    `json:"template_name"`
	Status       string    `json:"status"`
	Progress     int       `json:"progress"`
	CurrentStep  string    `json:"current_step,omitempty"`
	Error        string    `json:"error,omitempty"`
	StartedAt    time.Time `json:"started_at"`
}

AMIBuildResponse represents an AMI build job

type AMIRegionResponse

type AMIRegionResponse struct {
	Name     string `json:"name"`
	AMICount int    `json:"ami_count"`
}

AMIRegionResponse represents AMI regional coverage

type AMIResponse

type AMIResponse struct {
	ID           string    `json:"id"`
	TemplateName string    `json:"template_name"`
	Region       string    `json:"region"`
	State        string    `json:"state"`
	Architecture string    `json:"architecture"`
	SizeGB       float64   `json:"size_gb"`
	Description  string    `json:"description,omitempty"`
	CreatedAt    time.Time `json:"created_at"`
}

AMIResponse represents an AMI

type BudgetStatus

type BudgetStatus struct {
	TotalBudget              float64  `json:"total_budget"`
	SpentAmount              float64  `json:"spent_amount"`
	SpentPercentage          float64  `json:"spent_percentage"`
	ActiveAlerts             []string `json:"active_alerts"`
	ProjectedMonthlySpend    float64  `json:"projected_monthly_spend,omitempty"`
	DaysUntilBudgetExhausted *int     `json:"days_until_budget_exhausted,omitempty"`
}

BudgetStatus represents budget status for a project

type CategoryResponse

type CategoryResponse struct {
	Name          string `json:"name"`
	Description   string `json:"description"`
	TemplateCount int    `json:"template_count"`
}

CategoryResponse represents a template category

type GetRightsizingRecommendationsResponse

type GetRightsizingRecommendationsResponse struct {
	Recommendations []RightsizingRecommendation `json:"recommendations"`
}

GetRightsizingRecommendationsResponse represents a list of rightsizing recommendations

type IdleDetectionResponse

type IdleDetectionResponse struct {
	Enabled        bool      `json:"enabled"`
	Policy         string    `json:"policy"`
	IdleTime       int       `json:"idle_time"`       // Minutes
	Threshold      int       `json:"threshold"`       // Minutes
	ActionSchedule time.Time `json:"action_schedule"` // When action will occur
	ActionPending  bool      `json:"action_pending"`  // Whether action is pending
}

IdleDetectionResponse represents idle detection status for an instance

type IdlePolicyResponse

type IdlePolicyResponse struct {
	Name      string `json:"name"`
	Threshold int    `json:"threshold"` // Minutes
	Action    string `json:"action"`    // stop, terminate, etc.
}

IdlePolicyResponse represents an idle detection policy

type IdlePolicyUpdateRequest

type IdlePolicyUpdateRequest struct {
	Name      string `json:"name"`
	Threshold int    `json:"threshold"`
	Action    string `json:"action"`
}

IdlePolicyUpdateRequest represents a request to update an idle policy

type InstanceResponse

type InstanceResponse struct {
	ID                 string    `json:"id"`
	Name               string    `json:"name"`
	Template           string    `json:"template"`
	PublicIP           string    `json:"public_ip"`
	PrivateIP          string    `json:"private_ip"`
	State              string    `json:"state"`
	LaunchTime         time.Time `json:"launch_time"`
	HourlyRate         float64   `json:"hourly_rate"`    // AWS list price per hour
	CurrentSpend       float64   `json:"current_spend"`  // Actual accumulated cost since launch
	EffectiveRate      float64   `json:"effective_rate"` // Current spend ÷ hours since launch
	AttachedVolumes    []string  `json:"attached_volumes"`
	AttachedEBSVolumes []string  `json:"attached_ebs_volumes"`
	InstanceLifecycle  string    `json:"instance_lifecycle"` // "spot" or "on-demand"
	Ports              []int     `json:"ports"`
}

InstanceResponse represents an instance returned from the API

func ToInstanceResponse

func ToInstanceResponse(instance types.Instance) InstanceResponse

ToInstanceResponse converts a types.Instance to an InstanceResponse

type LaunchInstanceRequest

type LaunchInstanceRequest struct {
	Template   string   `json:"template"`
	Name       string   `json:"name"`
	Size       string   `json:"size,omitempty"`
	Volumes    []string `json:"volumes,omitempty"`
	EBSVolumes []string `json:"ebs_volumes,omitempty"`
	Region     string   `json:"region,omitempty"`
	Spot       bool     `json:"spot,omitempty"`
	DryRun     bool     `json:"dry_run,omitempty"`
}

LaunchInstanceRequest represents a request to launch an instance

type LaunchInstanceResponse

type LaunchInstanceResponse struct {
	Instance       InstanceResponse `json:"instance"`
	Message        string           `json:"message"`
	EstimatedCost  string           `json:"estimated_cost"`
	ConnectionInfo string           `json:"connection_info"`
}

LaunchInstanceResponse represents a successful launch response

type ListAMIBuildsResponse

type ListAMIBuildsResponse struct {
	Builds []AMIBuildResponse `json:"builds"`
}

ListAMIBuildsResponse represents a list of AMI builds

type ListAMIRegionsResponse

type ListAMIRegionsResponse struct {
	Regions []AMIRegionResponse `json:"regions"`
}

ListAMIRegionsResponse represents a list of AMI regions

type ListAMIsResponse

type ListAMIsResponse struct {
	AMIs []AMIResponse `json:"amis"`
}

ListAMIsResponse represents a list of AMIs

type ListCategoriesResponse

type ListCategoriesResponse struct {
	Categories []CategoryResponse `json:"categories"`
}

ListCategoriesResponse represents a list of categories

type ListIdlePoliciesResponse

type ListIdlePoliciesResponse struct {
	Policies map[string]IdlePolicyResponse `json:"policies"`
}

ListIdlePoliciesResponse represents a list of idle detection policies

type ListInstancesResponse

type ListInstancesResponse struct {
	Instances []InstanceResponse `json:"instances"`
	TotalCost float64            `json:"total_cost"`
}

ListInstancesResponse represents a list of instances returned from the API

func ToListInstancesResponse

func ToListInstancesResponse(resp *types.ListResponse) *ListInstancesResponse

ToListInstancesResponse converts a types.ListResponse to a ListInstancesResponse

type ListMarketplaceTemplatesResponse

type ListMarketplaceTemplatesResponse struct {
	Templates []MarketplaceTemplateResponse `json:"templates"`
}

ListMarketplaceTemplatesResponse represents a list of marketplace templates

type ListPolicySetsResponse

type ListPolicySetsResponse struct {
	PolicySets []PolicySetResponse `json:"policy_sets"`
}

ListPolicySetsResponse represents a list of policy sets

type ListProjectsResponse

type ListProjectsResponse struct {
	Projects []ProjectResponse `json:"projects"`
}

ListProjectsResponse represents a list of projects returned from the API

type ListRegistriesResponse

type ListRegistriesResponse struct {
	Registries []RegistryResponse `json:"registries"`
}

ListRegistriesResponse represents a list of registries

type ListStorageResponse

type ListStorageResponse struct {
	Storage map[string]StorageResponse `json:"storage"`
}

ListStorageResponse represents a list of EBS volumes returned from the API

func ToListStorageResponse

func ToListStorageResponse(storage []*types.StorageVolume) *ListStorageResponse

ToListStorageResponse converts a slice of types.StorageVolume to a ListStorageResponse

type ListTemplatesResponse

type ListTemplatesResponse struct {
	Templates map[string]TemplateResponse `json:"templates"`
}

ListTemplatesResponse represents a list of templates returned from the API

func ToListTemplatesResponse

func ToListTemplatesResponse(templates map[string]types.Template) *ListTemplatesResponse

ToListTemplatesResponse converts a map of types.Template to a ListTemplatesResponse

type ListVolumesResponse

type ListVolumesResponse struct {
	Volumes map[string]VolumeResponse `json:"volumes"`
}

ListVolumesResponse represents a list of EFS volumes returned from the API

func ToListVolumesResponse

func ToListVolumesResponse(volumes []*types.StorageVolume) *ListVolumesResponse

ToListVolumesResponse converts a slice of types.StorageVolume to a ListVolumesResponse

type LogsResponse

type LogsResponse struct {
	Lines []string `json:"lines"`
}

LogsResponse represents logs from an instance

type MarketplaceFilter

type MarketplaceFilter struct {
	Query     string  `json:"query,omitempty"`
	Category  string  `json:"category,omitempty"`
	Registry  string  `json:"registry,omitempty"`
	Verified  bool    `json:"verified,omitempty"`
	MinRating float64 `json:"min_rating,omitempty"`
}

MarketplaceFilter represents filters for listing marketplace templates

type MarketplaceTemplateResponse

type MarketplaceTemplateResponse struct {
	Name         string   `json:"name"`
	Publisher    string   `json:"publisher"`
	Category     string   `json:"category"`
	Description  string   `json:"description"`
	Rating       float64  `json:"rating"`
	RatingCount  int      `json:"rating_count"`
	Downloads    int64    `json:"downloads"`
	Verified     bool     `json:"verified"`
	Keywords     []string `json:"keywords"`
	SourceURL    string   `json:"source_url,omitempty"`
	License      string   `json:"license,omitempty"`
	Registry     string   `json:"registry,omitempty"`
	RegistryType string   `json:"registry_type,omitempty"`
}

MarketplaceTemplateResponse represents a template from the marketplace

type PolicySetResponse

type PolicySetResponse struct {
	ID          string `json:"id"`
	Description string `json:"description"`
	PolicyCount int    `json:"policy_count"`
	Status      string `json:"status"`
}

PolicySetResponse represents a policy set

type PolicyStatusResponse

type PolicyStatusResponse struct {
	Enabled          bool     `json:"enabled"`
	AssignedPolicies []string `json:"assigned_policies"`
	Message          string   `json:"message,omitempty"`
	StatusIcon       string   `json:"status_icon,omitempty"`
}

PolicyStatusResponse represents policy framework status

type ProjectFilter

type ProjectFilter struct {
	Status string `json:"status,omitempty"`
	Owner  string `json:"owner,omitempty"`
}

ProjectFilter represents filters for listing projects

type ProjectResponse

type ProjectResponse struct {
	ID              string        `json:"id"`
	Name            string        `json:"name"`
	Description     string        `json:"description,omitempty"`
	Owner           string        `json:"owner"`
	Status          string        `json:"status"`
	MemberCount     int           `json:"member_count"`
	ActiveInstances int           `json:"active_instances"`
	TotalCost       float64       `json:"total_cost"`
	BudgetStatus    *BudgetStatus `json:"budget_status,omitempty"`
	CreatedAt       time.Time     `json:"created_at"`
	LastActivity    time.Time     `json:"last_activity"`
}

ProjectResponse represents a project returned from the API

type RegistryResponse

type RegistryResponse struct {
	Name          string `json:"name"`
	Type          string `json:"type"` // community, institutional, private, official
	URL           string `json:"url"`
	TemplateCount int    `json:"template_count"`
	Status        string `json:"status"` // active, inactive, syncing
}

RegistryResponse represents a template registry

type RightsizingRecommendation

type RightsizingRecommendation struct {
	InstanceName      string  `json:"instance_name"`
	CurrentType       string  `json:"current_type"`
	RecommendedType   string  `json:"recommended_type"`
	CPUUtilization    float64 `json:"cpu_utilization"`
	MemoryUtilization float64 `json:"memory_utilization"`
	CurrentCost       float64 `json:"current_cost"`
	RecommendedCost   float64 `json:"recommended_cost"`
	MonthlySavings    float64 `json:"monthly_savings"`
	SavingsPercentage float64 `json:"savings_percentage"`
	Confidence        string  `json:"confidence"` // high, medium, low
	Reason            string  `json:"reason,omitempty"`
}

RightsizingRecommendation represents an instance rightsizing recommendation

type StorageResponse

type StorageResponse struct {
	Name            string    `json:"name"`
	VolumeID        string    `json:"volume_id"`
	Region          string    `json:"region"`
	CreationTime    time.Time `json:"creation_time"`
	State           string    `json:"state"`
	VolumeType      string    `json:"volume_type"`
	SizeGB          int32     `json:"size_gb"`
	IOPS            int32     `json:"iops"`
	Throughput      int32     `json:"throughput"`
	EstimatedCostGB float64   `json:"estimated_cost_gb"`
	AttachedTo      string    `json:"attached_to"`
}

StorageResponse represents an EBS volume returned from the API

func ToStorageResponse

func ToStorageResponse(storage types.StorageVolume) StorageResponse

ToStorageResponse converts a types.StorageVolume (workspace/EBS) to a StorageResponse

type SystemStatusResponse

type SystemStatusResponse struct {
	Version           string    `json:"version"`
	Status            string    `json:"status"`
	StartTime         time.Time `json:"start_time"`
	Uptime            string    `json:"uptime,omitempty"`
	ActiveOps         int       `json:"active_ops"`
	TotalRequests     int64     `json:"total_requests"`
	RequestsPerMinute float64   `json:"requests_per_minute,omitempty"`
	AWSRegion         string    `json:"aws_region"`
	AWSProfile        string    `json:"aws_profile,omitempty"`
	CurrentProfile    string    `json:"current_profile,omitempty"`
}

SystemStatusResponse represents daemon status information

func ToSystemStatusResponse

func ToSystemStatusResponse(status *types.DaemonStatus) *SystemStatusResponse

ToSystemStatusResponse converts daemon status to TUI response format

type TUIClient

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

TUIClient wraps the PrismAPI interface to provide a consistent interface for the TUI models.

func NewTUIClient

func NewTUIClient(client pkgapi.PrismAPI) *TUIClient

NewTUIClient creates a new TUIClient.

func (*TUIClient) ApplyRightsizingRecommendation

func (c *TUIClient) ApplyRightsizingRecommendation(ctx context.Context, instanceName string) error

ApplyRightsizingRecommendation applies a rightsizing recommendation

func (*TUIClient) AssignPolicySet

func (c *TUIClient) AssignPolicySet(ctx context.Context, policySetID string) error

AssignPolicySet assigns a policy set to the current user

func (*TUIClient) CheckTemplateAccess

func (c *TUIClient) CheckTemplateAccess(ctx context.Context, templateName string) (*TemplateAccessResponse, error)

CheckTemplateAccess checks if the user has access to a template

func (*TUIClient) DeleteAMI

func (c *TUIClient) DeleteAMI(ctx context.Context, amiID string) error

DeleteAMI deletes an AMI

func (*TUIClient) DeleteInstance

func (c *TUIClient) DeleteInstance(ctx context.Context, name string) error

DeleteInstance terminates an instance

func (*TUIClient) DisableIdleDetection

func (c *TUIClient) DisableIdleDetection(ctx context.Context, name string) error

DisableIdleDetection disables idle detection for an instance

func (*TUIClient) EnableIdleDetection

func (c *TUIClient) EnableIdleDetection(ctx context.Context, name, policy string) error

EnableIdleDetection enables idle detection for an instance

func (*TUIClient) GetInstance

func (c *TUIClient) GetInstance(ctx context.Context, name string) (*InstanceResponse, error)

GetInstance returns a specific instance

func (*TUIClient) GetInstanceIdleStatus

func (c *TUIClient) GetInstanceIdleStatus(ctx context.Context, name string) (*IdleDetectionResponse, error)

GetInstanceIdleStatus returns idle detection status for an instance

func (*TUIClient) GetLogs

func (c *TUIClient) GetLogs(ctx context.Context, instanceName, logType string) (*LogsResponse, error)

GetLogs retrieves logs for an instance

func (*TUIClient) GetPolicyStatus

func (c *TUIClient) GetPolicyStatus(ctx context.Context) (*PolicyStatusResponse, error)

GetPolicyStatus returns the current policy enforcement status

func (*TUIClient) GetRightsizingRecommendations

func (c *TUIClient) GetRightsizingRecommendations(ctx context.Context) (*GetRightsizingRecommendationsResponse, error)

GetRightsizingRecommendations returns rightsizing recommendations for all instances

func (*TUIClient) GetStatus

func (c *TUIClient) GetStatus(ctx context.Context) (*SystemStatusResponse, error)

GetStatus returns the daemon status information

func (*TUIClient) GetTemplate

func (c *TUIClient) GetTemplate(ctx context.Context, name string) (*TemplateResponse, error)

GetTemplate returns a specific template

func (*TUIClient) InstallMarketplaceTemplate

func (c *TUIClient) InstallMarketplaceTemplate(ctx context.Context, templateName string) error

InstallMarketplaceTemplate installs a template from the marketplace

func (*TUIClient) LaunchInstance

LaunchInstance launches a new instance

func (*TUIClient) ListAMIBuilds

func (c *TUIClient) ListAMIBuilds(ctx context.Context) (*ListAMIBuildsResponse, error)

ListAMIBuilds returns all AMI build jobs

func (*TUIClient) ListAMIRegions

func (c *TUIClient) ListAMIRegions(ctx context.Context) (*ListAMIRegionsResponse, error)

ListAMIRegions returns AMI regional coverage

func (*TUIClient) ListAMIs

func (c *TUIClient) ListAMIs(ctx context.Context) (*ListAMIsResponse, error)

ListAMIs returns all available AMIs

func (*TUIClient) ListIdlePolicies

func (c *TUIClient) ListIdlePolicies(ctx context.Context) (*ListIdlePoliciesResponse, error)

ListIdlePolicies returns all idle detection policies

func (*TUIClient) ListInstances

func (c *TUIClient) ListInstances(ctx context.Context) (*ListInstancesResponse, error)

ListInstances returns all instances

func (*TUIClient) ListMarketplaceCategories

func (c *TUIClient) ListMarketplaceCategories(ctx context.Context) (*ListCategoriesResponse, error)

ListMarketplaceCategories returns all marketplace categories

func (*TUIClient) ListMarketplaceRegistries

func (c *TUIClient) ListMarketplaceRegistries(ctx context.Context) (*ListRegistriesResponse, error)

ListMarketplaceRegistries returns all configured template registries

func (*TUIClient) ListMarketplaceTemplates

func (c *TUIClient) ListMarketplaceTemplates(ctx context.Context, filter *MarketplaceFilter) (*ListMarketplaceTemplatesResponse, error)

ListMarketplaceTemplates returns all marketplace templates with optional filtering

func (*TUIClient) ListPolicySets

func (c *TUIClient) ListPolicySets(ctx context.Context) (*ListPolicySetsResponse, error)

ListPolicySets returns all available policy sets

func (*TUIClient) ListProjects

func (c *TUIClient) ListProjects(ctx context.Context, filter *ProjectFilter) (*ListProjectsResponse, error)

ListProjects returns all projects with optional filtering

func (*TUIClient) ListStorage

func (c *TUIClient) ListStorage(ctx context.Context) (*ListStorageResponse, error)

ListStorage returns all EBS volumes

func (*TUIClient) ListTemplates

func (c *TUIClient) ListTemplates(ctx context.Context) (*ListTemplatesResponse, error)

ListTemplates returns all available templates

func (*TUIClient) ListVolumes

func (c *TUIClient) ListVolumes(ctx context.Context) (*ListVolumesResponse, error)

ListVolumes returns all EFS volumes

func (*TUIClient) MountVolume

func (c *TUIClient) MountVolume(ctx context.Context, volumeName, instanceName, mountPoint string) error

MountVolume mounts an EFS volume to an instance

func (*TUIClient) Ping

func (c *TUIClient) Ping(ctx context.Context) error

Ping checks if the daemon is responsive

func (*TUIClient) SetPolicyEnforcement

func (c *TUIClient) SetPolicyEnforcement(ctx context.Context, enabled bool) error

SetPolicyEnforcement enables or disables policy enforcement

func (*TUIClient) StartInstance

func (c *TUIClient) StartInstance(ctx context.Context, name string) error

StartInstance starts a stopped instance

func (*TUIClient) StopInstance

func (c *TUIClient) StopInstance(ctx context.Context, name string) error

StopInstance stops a running instance

func (*TUIClient) UnmountVolume

func (c *TUIClient) UnmountVolume(ctx context.Context, volumeName, instanceName string) error

UnmountVolume unmounts an EFS volume from an instance

func (*TUIClient) UpdateIdlePolicy

func (c *TUIClient) UpdateIdlePolicy(ctx context.Context, req IdlePolicyUpdateRequest) error

UpdateIdlePolicy updates an idle detection policy

type TemplateAccessResponse

type TemplateAccessResponse struct {
	Allowed         bool     `json:"allowed"`
	TemplateName    string   `json:"template_name"`
	Reason          string   `json:"reason,omitempty"`
	MatchedPolicies []string `json:"matched_policies,omitempty"`
	Suggestions     []string `json:"suggestions,omitempty"`
}

TemplateAccessResponse represents template access check result

type TemplateResponse

type TemplateResponse struct {
	Name          string             `json:"name"`
	Description   string             `json:"description"`
	AMI           map[string]string  `json:"ami"` // Simplified from original structure
	InstanceType  map[string]string  `json:"instance_type"`
	UserData      string             `json:"user_data"`
	Ports         []int              `json:"ports"`
	EstimatedCost map[string]float64 `json:"estimated_cost"`
}

TemplateResponse represents a template returned from the API

func ToTemplateResponse

func ToTemplateResponse(name string, template types.Template) TemplateResponse

ToTemplateResponse converts a types.Template to a TemplateResponse

type VolumeResponse

type VolumeResponse struct {
	Name            string    `json:"name"`
	FileSystemId    string    `json:"filesystem_id"`
	Region          string    `json:"region"`
	CreationTime    time.Time `json:"creation_time"`
	State           string    `json:"state"`
	PerformanceMode string    `json:"performance_mode"`
	ThroughputMode  string    `json:"throughput_mode"`
	EstimatedCostGB float64   `json:"estimated_cost_gb"`
	SizeBytes       int64     `json:"size_bytes"`
}

VolumeResponse represents an EFS volume returned from the API

func ToVolumeResponse

func ToVolumeResponse(volume types.StorageVolume) VolumeResponse

ToVolumeResponse converts a types.StorageVolume (shared/EFS) to a VolumeResponse

Jump to

Keyboard shortcuts

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