webui

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: Apache-2.0 Imports: 28 Imported by: 0

README

Nephoran Web UI Integration

This package provides a comprehensive Web UI integration layer for the Nephoran Intent Operator, enabling complete REST API access and real-time streaming capabilities for the Nephio UI.

Overview

The Web UI integration provides:

  • RESTful APIs: Complete CRUD operations for intents, packages, and clusters
  • Real-time Streaming: WebSocket and Server-Sent Events for live updates
  • Authentication: OAuth2 integration with RBAC authorization
  • Performance Optimization: Intelligent caching and rate limiting
  • OpenAPI Documentation: Complete API specification and interactive docs

Architecture

graph TB
    UI[Nephio Web UI] --> API[Nephoran API Server]
    API --> Auth[Authentication Middleware]
    API --> Cache[Caching Layer]
    API --> RL[Rate Limiter]
    
    API --> IM[Intent Manager]
    API --> PM[Package Manager]
    API --> CM[Cluster Manager]
    
    API --> WS[WebSocket Handler]
    API --> SSE[SSE Handler]
    
    WS --> Clients[WebSocket Clients]
    SSE --> Clients2[SSE Clients]

Key Components

1. API Server (server.go)
  • HTTP/HTTPS server with configurable TLS
  • Middleware pipeline for auth, caching, rate limiting
  • Graceful shutdown and connection management
  • Prometheus metrics integration
  • CORS support for cross-origin requests
2. Intent Management APIs (intent_handlers.go)
  • Full CRUD operations for NetworkIntent resources
  • Advanced filtering and pagination
  • Status tracking and progress monitoring
  • Bulk operations support
  • Integration with LLM processor for intent translation
3. Package Management APIs (package_handlers.go)
  • PackageRevision lifecycle management
  • Transition operations (Draft → Proposed → Published)
  • Validation and approval workflows
  • Multi-cluster deployment status
  • Template and blueprint management
4. Multi-Cluster APIs (cluster_handlers.go)
  • Cluster registration and management
  • Health monitoring and resource utilization
  • Deployment orchestration across clusters
  • Network topology visualization
  • Connectivity testing and latency metrics
5. Real-time Streaming (realtime_handlers.go)
  • WebSocket endpoints for bidirectional communication
  • Server-Sent Events for unidirectional streaming
  • Subscription filtering and event routing
  • Connection lifecycle management
  • Automatic reconnection and heartbeat
6. Performance Optimization
  • Caching (cache.go): LRU cache with TTL and intelligent invalidation
  • Rate Limiting (rate_limiter.go): Token bucket with sliding window
  • Connection pooling and resource optimization
  • Response compression and efficient serialization
7. Dashboard APIs (dashboard_handlers.go)
  • Comprehensive metrics aggregation
  • Real-time system health monitoring
  • Alert management and event tracking
  • Performance analytics and trend data
  • Network topology and dependency visualization
8. OpenAPI Documentation (openapi.go)
  • Complete OpenAPI 3.0 specification
  • Interactive Swagger UI documentation
  • Schema definitions and examples
  • Security scheme documentation
  • Automated API validation

API Endpoints

Intent Management
GET    /api/v1/intents                 - List intents
POST   /api/v1/intents                 - Create intent
GET    /api/v1/intents/{name}          - Get intent details
PUT    /api/v1/intents/{name}          - Update intent
DELETE /api/v1/intents/{name}          - Delete intent
GET    /api/v1/intents/{name}/status   - Get intent status
POST   /api/v1/intents/{name}/validate - Validate intent
Package Management
GET    /api/v1/packages                    - List packages
GET    /api/v1/packages/{name}             - Get package details
POST   /api/v1/packages/{name}/propose     - Transition to Proposed
POST   /api/v1/packages/{name}/approve     - Approve and publish
POST   /api/v1/packages/{name}/validate    - Validate package
GET    /api/v1/packages/{name}/deployment-status - Get deployment status
Multi-Cluster Management
GET    /api/v1/clusters                - List clusters
POST   /api/v1/clusters                - Register cluster
GET    /api/v1/clusters/{id}           - Get cluster details
GET    /api/v1/clusters/{id}/status    - Get cluster status
POST   /api/v1/clusters/{id}/deploy    - Deploy to cluster
GET    /api/v1/clusters/topology       - Get network topology
Real-time Streaming
WebSocket /api/v1/realtime/ws          - All events
WebSocket /api/v1/realtime/ws/intents  - Intent events only
WebSocket /api/v1/realtime/ws/packages - Package events only
WebSocket /api/v1/realtime/ws/clusters - Cluster events only

SSE /api/v1/realtime/events            - All events stream
SSE /api/v1/realtime/events/intents    - Intent events stream
SSE /api/v1/realtime/events/packages   - Package events stream
SSE /api/v1/realtime/events/clusters   - Cluster events stream
Dashboard and Metrics
GET /api/v1/dashboard/metrics          - Complete dashboard metrics
GET /api/v1/dashboard/overview         - System overview
GET /api/v1/dashboard/health           - System health status
GET /api/v1/dashboard/alerts           - Active alerts
GET /api/v1/dashboard/trends/intents   - Intent trend data
System Management
GET /health                            - Health check
GET /readiness                         - Readiness check  
GET /metrics                           - Prometheus metrics
GET /openapi.json                      - OpenAPI specification
GET /docs                              - Swagger UI documentation

Configuration

The API server is configured through the ServerConfig structure:

config := &ServerConfig{
    Address:           "0.0.0.0",
    Port:              8080,
    TLSEnabled:        false,
    TLSCertFile:       "/etc/certs/tls.crt",
    TLSKeyFile:        "/etc/certs/tls.key",
    EnableCORS:        true,
    AllowedOrigins:    []string{"*"},
    EnableRateLimit:   true,
    RequestsPerMin:    1000,
    EnableCaching:     true,
    CacheSize:         1000,
    CacheTTL:          5 * time.Minute,
    MaxWSConnections:  100,
    DefaultPageSize:   20,
    MaxPageSize:       100,
}

Authentication and Authorization

The API integrates with the existing Nephoran authentication system:

  • OAuth2 Providers: Azure AD, Okta, Keycloak, Google
  • JWT Tokens: Stateless authentication with refresh tokens
  • RBAC: Role-based access control with permissions
  • Session Management: Server-side session tracking
  • API Keys: For service-to-service communication
Permission Requirements
Endpoint Category Required Permission
Intent Read intent:read
Intent Create/Update intent:create, intent:update
Intent Delete intent:delete
Package Operations intent:update (lifecycle operations)
Cluster Operations system:manage
Dashboard/Metrics metrics:view
System Admin system:manage (admin endpoints)

Real-time Features

WebSocket Integration

WebSocket connections support:

  • Subscription Filtering: Subscribe to specific event types
  • Real-time Updates: Live intent, package, and cluster status
  • Bidirectional Communication: Request/response and notifications
  • Connection Management: Automatic reconnection and heartbeat
  • Scalability: Support for hundreds of concurrent connections

Example WebSocket subscription:

const ws = new WebSocket('ws://localhost:8080/api/v1/realtime/ws/intents');

// Subscribe to high-priority intents only
ws.send(JSON.stringify({
    action: 'subscribe',
    filters: {
        priority: ['high', 'critical'],
        event_types: ['intent_update']
    }
}));

ws.onmessage = (event) => {
    const update = JSON.parse(event.data);
    console.log('Intent update:', update);
};
Server-Sent Events

SSE provides unidirectional streaming:

  • Event Streaming: Continuous event feed
  • Filtering: Query parameter based filtering
  • Reconnection: Automatic client reconnection
  • Keep-alive: Heartbeat to maintain connections

Example SSE consumption:

const eventSource = new EventSource('/api/v1/realtime/events/intents?priority=high');

eventSource.onmessage = (event) => {
    const data = JSON.parse(event.data);
    console.log('Intent event:', data);
};

Performance Optimizations

Intelligent Caching
  • Multi-level Cache: In-memory with TTL and LRU eviction
  • Cache Invalidation: Smart invalidation on resource changes
  • Cache Warming: Predictive cache population
  • Hit Rate Monitoring: Performance metrics and optimization
Rate Limiting
  • Token Bucket: Burst handling with sustained rate limits
  • Sliding Window: Accurate rate calculation over time windows
  • Per-User Limits: Individual rate limits based on authentication
  • Adaptive Limits: Dynamic rate adjustment based on load
Connection Management
  • Connection Pooling: Efficient resource utilization
  • Graceful Degradation: Fallback strategies during high load
  • Circuit Breakers: Fault isolation and recovery
  • Resource Monitoring: Memory and connection usage tracking

Monitoring and Observability

Metrics Collection
  • Request Metrics: Latency, throughput, error rates
  • Connection Metrics: WebSocket and SSE connection counts
  • Cache Metrics: Hit rates, eviction counts, memory usage
  • Rate Limit Metrics: Rejection rates, quota utilization
Health Monitoring
  • Health Endpoints: System health and readiness checks
  • Component Health: Individual service health status
  • Dependency Checks: External service availability
  • Alert Integration: Automated alert generation
Distributed Tracing
  • Request Tracing: End-to-end request tracking
  • Service Correlation: Cross-service request correlation
  • Performance Analysis: Bottleneck identification
  • Error Attribution: Error source tracking

Usage Examples

Creating an Intent
curl -X POST http://localhost:8080/api/v1/intents \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${JWT_TOKEN}" \
  -d '{
    "name": "deploy-amf-prod",
    "intent": "Deploy a high-availability AMF instance for production with auto-scaling",
    "intent_type": "deployment",
    "priority": "high",
    "target_components": ["AMF"],
    "target_namespace": "telecom-production"
  }'
Subscribing to Real-time Updates
// WebSocket for bidirectional communication
const ws = new WebSocket('ws://localhost:8080/api/v1/realtime/ws');

ws.onopen = () => {
    // Subscribe to all high-priority events
    ws.send(JSON.stringify({
        action: 'subscribe',
        filters: { priority: ['high', 'critical'] }
    }));
};

// Server-Sent Events for unidirectional streaming  
const events = new EventSource('/api/v1/realtime/events?priority=high');
events.onmessage = (event) => {
    const data = JSON.parse(event.data);
    updateUI(data);
};
Retrieving Dashboard Metrics
curl -H "Authorization: Bearer ${JWT_TOKEN}" \
  http://localhost:8080/api/v1/dashboard/metrics

Development and Testing

Running the Server
import (
    "context"
    "github.com/thc1006/nephoran-intent-operator/pkg/webui"
)

// Create server with dependencies
server, err := webui.NewNephoranAPIServer(
    intentManager,
    packageManager, 
    clusterManager,
    llmProcessor,
    kubeClient,
    config,
)

// Start server
ctx := context.Background()
err = server.Start(ctx)
Testing WebSocket Connections
# Test WebSocket connection
wscat -c ws://localhost:8080/api/v1/realtime/ws

# Test SSE stream  
curl -N -H "Accept: text/event-stream" \
  http://localhost:8080/api/v1/realtime/events
API Documentation

Integration with Nephio UI

The API server is designed specifically for integration with the Nephio Web UI:

UI Dashboard Integration
  • Real-time metrics display
  • Interactive intent creation and monitoring
  • Package lifecycle visualization
  • Multi-cluster deployment management
  • Alert and event management
Streaming Integration
  • Live status updates without polling
  • Real-time progress indicators
  • Immediate error notifications
  • Connection status monitoring
Security Integration
  • Single sign-on (SSO) compatibility
  • Role-based UI element visibility
  • Secure API token management
  • Session timeout handling

This comprehensive Web UI integration layer provides the Nephio UI with complete visibility and control over intent-driven network operations while maintaining enterprise-grade security, performance, and reliability standards.

Documentation

Overview

Package webui provides comprehensive Web UI integration for the Nephoran Intent Operator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Code string `json:"code"`

	Message string `json:"message"`

	Details interface{} `json:"details,omitempty"`

	RequestID string `json:"request_id,omitempty"`
}

type APIResponse

type APIResponse struct {
	Success bool `json:"success"`

	Data interface{} `json:"data,omitempty"`

	Error *APIError `json:"error,omitempty"`

	Meta *Meta `json:"meta,omitempty"`

	Links *Links `json:"links,omitempty"`

	Timestamp time.Time `json:"timestamp"`
}

type Cache

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

func NewCache

func NewCache(maxSize int, defaultTTL time.Duration) *Cache

func (*Cache) Clear

func (c *Cache) Clear()

func (*Cache) Delete

func (c *Cache) Delete(key string) bool

func (*Cache) Get

func (c *Cache) Get(key string) (interface{}, bool)

func (*Cache) HitRate

func (c *Cache) HitRate() float64

func (*Cache) Invalidate

func (c *Cache) Invalidate(keyPrefix string) int

func (*Cache) Keys

func (c *Cache) Keys() []string

func (*Cache) Set

func (c *Cache) Set(key string, value interface{})

func (*Cache) SetWithTTL

func (c *Cache) SetWithTTL(key string, value interface{}, ttl time.Duration)

func (*Cache) Size

func (c *Cache) Size() int

func (*Cache) Stats

func (c *Cache) Stats() *CacheStats

type CacheConfig

type CacheConfig struct {
	MaxSize int

	DefaultTTL time.Duration

	CleanupInterval time.Duration

	MaxItemSize int64
}

type CacheStats

type CacheStats struct {
	Hits int64

	Misses int64

	Sets int64

	Evictions int64

	ExpiredItems int64

	TotalItems int64

	TotalSize int64

	AvgItemSize float64
}

type ClusterHealthStatus

type ClusterHealthStatus struct {
	Overall string `json:"overall"`

	Components map[string]string `json:"components"`

	LastChecked *metav1.Time `json:"last_checked"`

	NextCheckIn time.Duration `json:"next_check_in"`

	HealthScore float64 `json:"health_score"` // 0-100

	Alerts []*HealthAlert `json:"alerts,omitempty"`

	Recommendations []*HealthRecommendation `json:"recommendations,omitempty"`
}

type ClusterRequest

type ClusterRequest struct {
	Name string `json:"name"`

	Region string `json:"region,omitempty"`

	Zone string `json:"zone,omitempty"`

	KubeConfig string `json:"kubeconfig,omitempty"` // Base64 encoded

	EdgeLocation *multicluster.EdgeLocation `json:"edge_location,omitempty"`

	Capabilities []string `json:"capabilities,omitempty"`

	Resources *multicluster.ResourceCapacity `json:"resources,omitempty"`

	Labels map[string]string `json:"labels,omitempty"`

	Annotations map[string]string `json:"annotations,omitempty"`
}

type ClusterResponse

type ClusterResponse struct {
	*multicluster.WorkloadCluster

	HealthStatus *ClusterHealthStatus `json:"health_status,omitempty"`

	DeploymentHistory []*DeploymentHistoryItem `json:"deployment_history,omitempty"`

	ResourceUsage *ResourceUsageMetrics `json:"resource_usage,omitempty"`

	NetworkInfo *NetworkInformation `json:"network_info,omitempty"`
}

type ClusterStatusUpdate

type ClusterStatusUpdate struct {
	ClusterName string `json:"cluster_name"`

	Status multicluster.ClusterStatus `json:"status"`

	PreviousStatus multicluster.ClusterStatus `json:"previous_status,omitempty"`

	HealthScore float64 `json:"health_score"`

	Message string `json:"message,omitempty"`

	Timestamp time.Time `json:"timestamp"`

	EventType string `json:"event_type"` // registered, updated, health_changed, deployment, error

	Alerts []*HealthAlert `json:"alerts,omitempty"`
}

type DeploymentHistoryItem

type DeploymentHistoryItem struct {
	PackageName string `json:"package_name"`

	Version string `json:"version"`

	Status string `json:"status"`

	DeployedAt *metav1.Time `json:"deployed_at"`

	DeployedBy string `json:"deployed_by,omitempty"`

	Duration *metav1.Duration `json:"duration,omitempty"`

	ErrorMessage string `json:"error_message,omitempty"`
}

type DeploymentRequest

type DeploymentRequest struct {
	PackageName string `json:"package_name"`

	TargetClusters []string `json:"target_clusters,omitempty"`

	Strategy multicluster.DeploymentStrategy `json:"strategy,omitempty"`

	Constraints []multicluster.PlacementConstraint `json:"constraints,omitempty"`

	ValidateOnly bool `json:"validate_only,omitempty"`

	DryRun bool `json:"dry_run,omitempty"`
}

type DeploymentStatus

type DeploymentStatus struct {
	PackageName string `json:"package_name,omitempty"`

	PackageRevision string `json:"package_revision,omitempty"`

	PackageStatus string `json:"package_status,omitempty"`

	DeployedClusters []string `json:"deployed_clusters,omitempty"`

	FailedClusters []string `json:"failed_clusters,omitempty"`

	ResourcesCreated int `json:"resources_created"`

	ResourcesFailed int `json:"resources_failed"`

	HealthStatus string `json:"health_status,omitempty"`

	LastHealthCheck *metav1.Time `json:"last_health_check,omitempty"`
}

type DeploymentTargetInfo

type DeploymentTargetInfo struct {
	ClusterName string `json:"cluster_name"`

	Status string `json:"status"`

	LastDeployed *metav1.Time `json:"last_deployed,omitempty"`

	Health string `json:"health,omitempty"`

	Version string `json:"version,omitempty"`

	ErrorMessage string `json:"error_message,omitempty"`
}

type FilterParams

type FilterParams struct {
	Status string `json:"status,omitempty"`

	Type string `json:"type,omitempty"`

	Priority string `json:"priority,omitempty"`

	Component string `json:"component,omitempty"`

	Cluster string `json:"cluster,omitempty"`

	Labels map[string]string `json:"labels,omitempty"`

	Since *time.Time `json:"since,omitempty"`

	Until *time.Time `json:"until,omitempty"`
}

type HealthAlert

type HealthAlert struct {
	Level string `json:"level"` // info, warning, error, critical

	Component string `json:"component"`

	Message string `json:"message"`

	Timestamp time.Time `json:"timestamp"`

	ActionURL string `json:"action_url,omitempty"`
}

type HealthRecommendation

type HealthRecommendation struct {
	Title string `json:"title"`

	Description string `json:"description"`

	Priority string `json:"priority"` // low, medium, high, critical

	Category string `json:"category"` // performance, security, reliability

	ActionURL string `json:"action_url,omitempty"`
}

type IngressControllerInfo

type IngressControllerInfo struct {
	Name string `json:"name"`

	Class string `json:"class"`

	Status string `json:"status"`

	LoadBalancer string `json:"load_balancer,omitempty"`
}

type IntentRequest

type IntentRequest struct {
	Name string `json:"name"`

	Intent string `json:"intent"`

	IntentType nephoranv1.IntentType `json:"intent_type"`

	Priority nephoranv1.NetworkPriority `json:"priority,omitempty"`

	TargetComponents []nephoranv1.TargetComponent `json:"target_components,omitempty"`

	ResourceConstraints *nephoranv1.ResourceConstraints `json:"resource_constraints,omitempty"`

	TargetCluster string `json:"target_cluster,omitempty"`

	NetworkSlice string `json:"network_slice,omitempty"`

	Region string `json:"region,omitempty"`

	TimeoutSeconds *int32 `json:"timeout_seconds,omitempty"`

	MaxRetries *int32 `json:"max_retries,omitempty"`

	Labels map[string]string `json:"labels,omitempty"`

	Annotations map[string]string `json:"annotations,omitempty"`
}

type IntentResponse

type IntentResponse struct {
	*nephoranv1.NetworkIntent

	ProcessingMetrics *ProcessingMetrics `json:"processing_metrics,omitempty"`

	DeploymentStatus *DeploymentStatus `json:"deployment_status,omitempty"`

	ValidationResult *ValidationSummary `json:"validation_result,omitempty"`
}

type IntentStatusUpdate

type IntentStatusUpdate struct {
	IntentName string `json:"intent_name"`

	Phase string `json:"phase"`

	Conditions []metav1.Condition `json:"conditions,omitempty"`

	Progress int `json:"progress"` // 0-100

	Message string `json:"message,omitempty"`

	Timestamp time.Time `json:"timestamp"`

	EventType string `json:"event_type"` // created, updated, deleted, error
}
type Links struct {
	Self string `json:"self"`

	First string `json:"first,omitempty"`

	Last string `json:"last,omitempty"`

	Previous string `json:"previous,omitempty"`

	Next string `json:"next,omitempty"`
}

type LoadBalancerInfo

type LoadBalancerInfo struct {
	Name string `json:"name"`

	Type string `json:"type"`

	ExternalIP string `json:"external_ip,omitempty"`

	Status string `json:"status"`
}

type Meta

type Meta struct {
	Page int `json:"page"`

	PageSize int `json:"page_size"`

	TotalPages int `json:"total_pages"`

	TotalItems int `json:"total_items"`
}

type MetricsUpdate

type MetricsUpdate struct {
	MetricName string `json:"metric_name"`

	Value float64 `json:"value"`

	Labels map[string]string `json:"labels,omitempty"`

	Timestamp time.Time `json:"timestamp"`

	Unit string `json:"unit,omitempty"`
}

type NephoranAPIServer

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

func NewNephoranAPIServer

func NewNephoranAPIServer(
	intentReconciler *controllers.NetworkIntentReconciler,

	packageManager packagerevision.PackageRevisionManager,

	clusterManager multicluster.ClusterPropagationManager,

	llmProcessor *services.LLMProcessorService,

	kubeClient kubernetes.Interface,

	config *ServerConfig,
) (*NephoranAPIServer, error)

func (*NephoranAPIServer) Shutdown

func (s *NephoranAPIServer) Shutdown() error

func (*NephoranAPIServer) Start

func (s *NephoranAPIServer) Start(ctx context.Context) error

type NetworkIO

type NetworkIO struct {
	BytesIn int64 `json:"bytes_in"`

	BytesOut int64 `json:"bytes_out"`

	PacketsIn int64 `json:"packets_in"`

	PacketsOut int64 `json:"packets_out"`
}

type NetworkInformation

type NetworkInformation struct {
	ClusterCIDR string `json:"cluster_cidr,omitempty"`

	ServiceCIDR string `json:"service_cidr,omitempty"`

	PodCIDR string `json:"pod_cidr,omitempty"`

	DNSClusterIP string `json:"dns_cluster_ip,omitempty"`

	LoadBalancers []*LoadBalancerInfo `json:"load_balancers,omitempty"`

	IngressControllers []*IngressControllerInfo `json:"ingress_controllers,omitempty"`
}

type OpenAPIComponents

type OpenAPIComponents struct {
	Schemas map[string]*OpenAPISchema `json:"schemas,omitempty"`

	Responses map[string]*OpenAPIResponse `json:"responses,omitempty"`

	Parameters map[string]*OpenAPIParameter `json:"parameters,omitempty"`

	RequestBodies map[string]*OpenAPIRequestBody `json:"requestBodies,omitempty"`

	Headers map[string]*OpenAPIHeader `json:"headers,omitempty"`

	SecuritySchemes map[string]*OpenAPISecurityScheme `json:"securitySchemes,omitempty"`
}

type OpenAPIContact

type OpenAPIContact struct {
	Name string `json:"name,omitempty"`

	URL string `json:"url,omitempty"`

	Email string `json:"email,omitempty"`
}

type OpenAPIContent

type OpenAPIContent struct {
	Schema *OpenAPISchema `json:"schema,omitempty"`

	Example interface{} `json:"example,omitempty"`

	Examples map[string]*OpenAPIExample `json:"examples,omitempty"`
}

type OpenAPIExample

type OpenAPIExample struct {
	Summary string `json:"summary,omitempty"`

	Description string `json:"description,omitempty"`

	Value interface{} `json:"value,omitempty"`
}

type OpenAPIExternalDocs

type OpenAPIExternalDocs struct {
	Description string `json:"description,omitempty"`

	URL string `json:"url"`
}

type OpenAPIHeader

type OpenAPIHeader struct {
	Description string `json:"description,omitempty"`

	Required bool `json:"required,omitempty"`

	Schema *OpenAPISchema `json:"schema,omitempty"`
}

type OpenAPIInfo

type OpenAPIInfo struct {
	Title string `json:"title"`

	Description string `json:"description"`

	Version string `json:"version"`

	Contact *OpenAPIContact `json:"contact,omitempty"`

	License *OpenAPILicense `json:"license,omitempty"`

	TermsOfService string `json:"termsOfService,omitempty"`
}

type OpenAPILicense

type OpenAPILicense struct {
	Name string `json:"name"`

	URL string `json:"url,omitempty"`
}

type OpenAPIOAuthFlow

type OpenAPIOAuthFlow struct {
	AuthorizationURL string `json:"authorizationUrl,omitempty"`

	TokenURL string `json:"tokenUrl,omitempty"`

	RefreshURL string `json:"refreshUrl,omitempty"`

	Scopes map[string]string `json:"scopes,omitempty"`
}

type OpenAPIOAuthFlows

type OpenAPIOAuthFlows struct {
	Implicit *OpenAPIOAuthFlow `json:"implicit,omitempty"`

	Password *OpenAPIOAuthFlow `json:"password,omitempty"`

	ClientCredentials *OpenAPIOAuthFlow `json:"clientCredentials,omitempty"`

	AuthorizationCode *OpenAPIOAuthFlow `json:"authorizationCode,omitempty"`
}

type OpenAPIOperation

type OpenAPIOperation struct {
	Tags []string `json:"tags,omitempty"`

	Summary string `json:"summary,omitempty"`

	Description string `json:"description,omitempty"`

	OperationID string `json:"operationId,omitempty"`

	Parameters []*OpenAPIParameter `json:"parameters,omitempty"`

	RequestBody *OpenAPIRequestBody `json:"requestBody,omitempty"`

	Responses map[string]*OpenAPIResponse `json:"responses"`

	Security []map[string][]string `json:"security,omitempty"`

	Deprecated bool `json:"deprecated,omitempty"`
}

type OpenAPIParameter

type OpenAPIParameter struct {
	Name string `json:"name"`

	In string `json:"in"` // query, header, path, cookie

	Description string `json:"description,omitempty"`

	Required bool `json:"required,omitempty"`

	Schema *OpenAPISchema `json:"schema,omitempty"`

	Example interface{} `json:"example,omitempty"`
}

type OpenAPIPath

type OpenAPIPath struct {
	Get *OpenAPIOperation `json:"get,omitempty"`

	Post *OpenAPIOperation `json:"post,omitempty"`

	Put *OpenAPIOperation `json:"put,omitempty"`

	Delete *OpenAPIOperation `json:"delete,omitempty"`

	Patch *OpenAPIOperation `json:"patch,omitempty"`
}

type OpenAPIRequestBody

type OpenAPIRequestBody struct {
	Description string `json:"description,omitempty"`

	Content map[string]*OpenAPIContent `json:"content"`

	Required bool `json:"required,omitempty"`
}

type OpenAPIResponse

type OpenAPIResponse struct {
	Description string `json:"description"`

	Headers map[string]*OpenAPIHeader `json:"headers,omitempty"`

	Content map[string]*OpenAPIContent `json:"content,omitempty"`
}

type OpenAPISchema

type OpenAPISchema struct {
	Type string `json:"type,omitempty"`

	Format string `json:"format,omitempty"`

	Title string `json:"title,omitempty"`

	Description string `json:"description,omitempty"`

	Default interface{} `json:"default,omitempty"`

	Example interface{} `json:"example,omitempty"`

	Enum []interface{} `json:"enum,omitempty"`

	Items *OpenAPISchema `json:"items,omitempty"`

	Properties map[string]*OpenAPISchema `json:"properties,omitempty"`

	Required []string `json:"required,omitempty"`

	AdditionalProperties interface{} `json:"additionalProperties,omitempty"`

	AllOf []*OpenAPISchema `json:"allOf,omitempty"`

	OneOf []*OpenAPISchema `json:"oneOf,omitempty"`

	AnyOf []*OpenAPISchema `json:"anyOf,omitempty"`

	Not *OpenAPISchema `json:"not,omitempty"`

	Ref string `json:"$ref,omitempty"`

	Minimum *float64 `json:"minimum,omitempty"`

	Maximum *float64 `json:"maximum,omitempty"`

	MinLength *int `json:"minLength,omitempty"`

	MaxLength *int `json:"maxLength,omitempty"`

	Pattern string `json:"pattern,omitempty"`
}

type OpenAPISecurityScheme

type OpenAPISecurityScheme struct {
	Type string `json:"type"`

	Description string `json:"description,omitempty"`

	Name string `json:"name,omitempty"`

	In string `json:"in,omitempty"`

	Scheme string `json:"scheme,omitempty"`

	BearerFormat string `json:"bearerFormat,omitempty"`

	Flows *OpenAPIOAuthFlows `json:"flows,omitempty"`

	OpenIDConnectURL string `json:"openIdConnectUrl,omitempty"`
}

type OpenAPIServer

type OpenAPIServer struct {
	URL string `json:"url"`

	Description string `json:"description,omitempty"`

	Variables map[string]*OpenAPIServerVariable `json:"variables,omitempty"`
}

type OpenAPIServerVariable

type OpenAPIServerVariable struct {
	Enum []string `json:"enum,omitempty"`

	Default string `json:"default"`

	Description string `json:"description,omitempty"`
}

type OpenAPISpec

type OpenAPISpec struct {
	OpenAPI string `json:"openapi"`

	Info *OpenAPIInfo `json:"info"`

	Servers []*OpenAPIServer `json:"servers,omitempty"`

	Paths map[string]*OpenAPIPath `json:"paths"`

	Components *OpenAPIComponents `json:"components,omitempty"`

	Security []map[string][]string `json:"security,omitempty"`

	Tags []*OpenAPITag `json:"tags,omitempty"`
}

type OpenAPITag

type OpenAPITag struct {
	Name string `json:"name"`

	Description string `json:"description,omitempty"`

	ExternalDocs *OpenAPIExternalDocs `json:"externalDocs,omitempty"`
}

type PackageRequest

type PackageRequest struct {
	PackageName string `json:"package_name"`

	Repository string `json:"repository,omitempty"`

	Revision string `json:"revision,omitempty"`

	Description string `json:"description,omitempty"`

	Labels map[string]string `json:"labels,omitempty"`

	Annotations map[string]string `json:"annotations,omitempty"`
}

type PackageResponse

type PackageResponse struct {
	*porch.PackageRevision

	LifecycleStatus *packagerevision.LifecycleStatus `json:"lifecycle_status,omitempty"`

	ValidationResults []*packagerevision.ValidationResult `json:"validation_results,omitempty"`

	ApprovalStatus *packagerevision.ApprovalResult `json:"approval_status,omitempty"`

	Metrics *packagerevision.PackageMetrics `json:"metrics,omitempty"`

	DeploymentTargets []DeploymentTargetInfo `json:"deployment_targets,omitempty"`
}

type PackageStatusUpdate

type PackageStatusUpdate struct {
	PackageName string `json:"package_name"`

	Repository string `json:"repository"`

	Revision string `json:"revision"`

	CurrentStage porch.PackageRevisionLifecycle `json:"current_stage"`

	PreviousStage porch.PackageRevisionLifecycle `json:"previous_stage,omitempty"`

	Progress int `json:"progress"` // 0-100

	Message string `json:"message,omitempty"`

	Timestamp time.Time `json:"timestamp"`

	EventType string `json:"event_type"` // created, transition, validation, approval, error

	Conditions []metav1.Condition `json:"conditions,omitempty"`
}

type PaginationParams

type PaginationParams struct {
	Page int `json:"page"`

	PageSize int `json:"page_size"`

	Sort string `json:"sort"`

	Order string `json:"order"`
}

type ProcessingMetrics

type ProcessingMetrics struct {
	ProcessingDuration *metav1.Duration `json:"processing_duration,omitempty"`

	DeploymentDuration *metav1.Duration `json:"deployment_duration,omitempty"`

	TotalDuration *metav1.Duration `json:"total_duration,omitempty"`

	QueueTime *metav1.Duration `json:"queue_time,omitempty"`

	LLMProcessingTime *metav1.Duration `json:"llm_processing_time,omitempty"`

	PackageCreationTime *metav1.Duration `json:"package_creation_time,omitempty"`

	GitOpsDeploymentTime *metav1.Duration `json:"gitops_deployment_time,omitempty"`
}

type RateLimitConfig

type RateLimitConfig struct {
	RequestsPerMin int

	BurstSize int

	Window time.Duration

	CleanupInterval time.Duration

	MaxBuckets int

	WhitelistIPs []string

	WhitelistUserIDs []string
}

type RateLimitInfo

type RateLimitInfo struct {
	Limit int `json:"limit"` // Requests per window

	Remaining int `json:"remaining"` // Remaining requests in current window

	ResetTime time.Time `json:"reset_time"` // When the window resets

	Burst int `json:"burst"` // Available burst tokens
}

type RateLimitStats

type RateLimitStats struct {
	TotalRequests int64

	AllowedRequests int64

	DeniedRequests int64

	ActiveBuckets int64

	ExpiredBuckets int64

	AvgRequestsPerMin float64
}

type RateLimiter

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

func NewRateLimiter

func NewRateLimiter(requestsPerMin, burstSize int, window time.Duration) *RateLimiter

func (*RateLimiter) Allow

func (rl *RateLimiter) Allow(identifier string) bool

func (*RateLimiter) AllowN

func (rl *RateLimiter) AllowN(identifier string, n int) bool

func (*RateLimiter) GetLimit

func (rl *RateLimiter) GetLimit(identifier string) *RateLimitInfo

func (*RateLimiter) IsRateLimited

func (rl *RateLimiter) IsRateLimited(identifier string) bool

func (*RateLimiter) RemoveLimit

func (rl *RateLimiter) RemoveLimit(identifier string)

func (*RateLimiter) Reset

func (rl *RateLimiter) Reset()

func (*RateLimiter) SetCustomLimit

func (rl *RateLimiter) SetCustomLimit(identifier string, requestsPerMin, burstSize int)

func (*RateLimiter) Stats

func (rl *RateLimiter) Stats() *RateLimitStats

func (*RateLimiter) Stop

func (rl *RateLimiter) Stop()

type ResourceUsageMetrics

type ResourceUsageMetrics struct {
	CPUUsage float64 `json:"cpu_usage_percent"`

	MemoryUsage float64 `json:"memory_usage_percent"`

	StorageUsage float64 `json:"storage_usage_percent"`

	NetworkIO *NetworkIO `json:"network_io,omitempty"`

	PodCount int `json:"pod_count"`

	NodeCount int `json:"node_count"`

	LastUpdated *metav1.Time `json:"last_updated"`
}

type SSEConnection

type SSEConnection struct {
	ID string

	UserID string

	Writer http.ResponseWriter

	Flusher http.Flusher

	Filters map[string]interface{}

	LastSeen time.Time
}

type ServerConfig

type ServerConfig struct {
	Address string `json:"address"`

	Port int `json:"port"`

	ReadTimeout time.Duration `json:"read_timeout"`

	WriteTimeout time.Duration `json:"write_timeout"`

	IdleTimeout time.Duration `json:"idle_timeout"`

	ShutdownTimeout time.Duration `json:"shutdown_timeout"`

	TLSEnabled bool `json:"tls_enabled"`

	TLSCertFile string `json:"tls_cert_file"`

	TLSKeyFile string `json:"tls_key_file"`

	EnableCORS bool `json:"enable_cors"`

	AllowedOrigins []string `json:"allowed_origins"`

	AllowedMethods []string `json:"allowed_methods"`

	AllowedHeaders []string `json:"allowed_headers"`

	AllowCredentials bool `json:"allow_credentials"`

	EnableRateLimit bool `json:"enable_rate_limit"`

	RequestsPerMin int `json:"requests_per_min"`

	BurstSize int `json:"burst_size"`

	RateLimitWindow time.Duration `json:"rate_limit_window"`

	EnableCaching bool `json:"enable_caching"`

	CacheSize int `json:"cache_size"`

	CacheTTL time.Duration `json:"cache_ttl"`

	MaxWSConnections int `json:"max_ws_connections"`

	WSTimeout time.Duration `json:"ws_timeout"`

	SSETimeout time.Duration `json:"sse_timeout"`

	PingInterval time.Duration `json:"ping_interval"`

	DefaultPageSize int `json:"default_page_size"`

	MaxPageSize int `json:"max_page_size"`

	EnableMetrics bool `json:"enable_metrics"`

	EnableProfiling bool `json:"enable_profiling"`

	EnableHealthCheck bool `json:"enable_health_check"`

	AuthConfigFile string `json:"auth_config_file"`
}

type ServerMetrics

type ServerMetrics struct {
	RequestsTotal *prometheus.CounterVec

	RequestDuration *prometheus.HistogramVec

	WSConnectionsActive prometheus.Gauge

	SSEConnectionsActive prometheus.Gauge

	CacheHits prometheus.Counter

	CacheMisses prometheus.Counter

	RateLimitExceeded prometheus.Counter
}

type StreamFilter

type StreamFilter struct {
	EventTypes []string `json:"event_types,omitempty"` // intent, package, cluster, deployment

	Status []string `json:"status,omitempty"` // pending, processing, completed, failed

	Priority []string `json:"priority,omitempty"` // low, medium, high, critical

	Components []string `json:"components,omitempty"` // AMF, SMF, UPF, etc.

	Clusters []string `json:"clusters,omitempty"` // cluster names/IDs

	Namespaces []string `json:"namespaces,omitempty"` // kubernetes namespaces

	Labels map[string]string `json:"labels,omitempty"` // label selectors

	Since *time.Time `json:"since,omitempty"` // events since timestamp
}

type StreamMessage

type StreamMessage struct {
	Type string `json:"type"` // intent_update, package_update, cluster_update, system_event

	ID string `json:"id"` // unique message ID

	Timestamp time.Time `json:"timestamp"`

	Source string `json:"source"` // source component/service

	Data interface{} `json:"data"` // actual event data

	Metadata json.RawMessage `json:"metadata,omitempty"`
}

type SystemEvent

type SystemEvent struct {
	Level string `json:"level"` // info, warning, error, critical

	Component string `json:"component"` // which component generated the event

	Event string `json:"event"` // event type

	Message string `json:"message"` // human-readable message

	Details json.RawMessage `json:"details,omitempty"`

	Timestamp time.Time `json:"timestamp"`
}

type TransitionRequest

type TransitionRequest struct {
	TargetStage string `json:"target_stage"`

	SkipValidation bool `json:"skip_validation,omitempty"`

	SkipApproval bool `json:"skip_approval,omitempty"`

	CreateRollbackPoint bool `json:"create_rollback_point,omitempty"`

	RollbackDescription string `json:"rollback_description,omitempty"`

	ForceTransition bool `json:"force_transition,omitempty"`

	ValidationPolicy *packagerevision.ValidationPolicy `json:"validation_policy,omitempty"`

	ApprovalPolicy *packagerevision.ApprovalPolicy `json:"approval_policy,omitempty"`

	NotificationTargets []string `json:"notification_targets,omitempty"`

	Metadata map[string]string `json:"metadata,omitempty"`

	DryRun bool `json:"dry_run,omitempty"`
}

type ValidationSummary

type ValidationSummary struct {
	Valid bool `json:"valid"`

	Errors []string `json:"errors,omitempty"`

	Warnings []string `json:"warnings,omitempty"`

	ValidationTime *metav1.Time `json:"validation_time,omitempty"`

	ValidatedBy string `json:"validated_by,omitempty"`
}

type WebSocketConnection

type WebSocketConnection struct {
	ID string

	UserID string

	Connection *websocket.Conn

	Send chan []byte

	Filters map[string]interface{}

	LastSeen time.Time
}

type WebSocketMessage

type WebSocketMessage struct {
	StreamMessage

	Action string `json:"action,omitempty"` // subscribe, unsubscribe, ping, pong

	Filters *StreamFilter `json:"filters,omitempty"` // subscription filters

	RequestID string `json:"request_id,omitempty"` // for request/response correlation
}

Jump to

Keyboard shortcuts

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