cloud

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AWSProvider

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

AWSProvider implements the CloudProvider interface for AWS

func (*AWSProvider) Connect

func (p *AWSProvider) Connect(ctx context.Context) error

Connect establishes connection to AWS

func (*AWSProvider) CreateResource

func (p *AWSProvider) CreateResource(ctx context.Context, req *CreateResourceRequest) (*Resource, error)

Additional methods to implement CloudProvider interface

func (*AWSProvider) DeleteResource

func (p *AWSProvider) DeleteResource(ctx context.Context, resourceID string) error

func (*AWSProvider) Disconnect

func (p *AWSProvider) Disconnect(ctx context.Context) error

Disconnect closes the connection

func (*AWSProvider) GetConfiguration

func (p *AWSProvider) GetConfiguration() *ProviderConfig

func (*AWSProvider) GetCost

func (p *AWSProvider) GetCost(ctx context.Context, req *CostRequest) (*CostResponse, error)

func (*AWSProvider) GetMetrics

func (p *AWSProvider) GetMetrics(ctx context.Context, req *MetricsRequest) (*MetricsResponse, error)

func (*AWSProvider) GetName

func (p *AWSProvider) GetName() string

GetName returns the provider name

func (*AWSProvider) GetRegions

func (p *AWSProvider) GetRegions(ctx context.Context) ([]string, error)

func (*AWSProvider) GetResourceDetails

func (p *AWSProvider) GetResourceDetails(ctx context.Context, resourceID string) (*Resource, error)

GetResourceDetails gets detailed information about a resource

func (*AWSProvider) GetResourceTypes

func (p *AWSProvider) GetResourceTypes(ctx context.Context) ([]string, error)

func (*AWSProvider) GetStatus

func (p *AWSProvider) GetStatus() *ProviderStatus

func (*AWSProvider) GetType

func (p *AWSProvider) GetType() string

GetType returns the provider type

func (*AWSProvider) IsConnected

func (p *AWSProvider) IsConnected() bool

IsConnected returns connection status

func (*AWSProvider) ListResources

func (p *AWSProvider) ListResources(ctx context.Context, resourceType string) ([]*Resource, error)

ListResources lists AWS resources

func (*AWSProvider) UpdateConfiguration

func (p *AWSProvider) UpdateConfiguration(config *ProviderConfig) error

func (*AWSProvider) UpdateResource

func (p *AWSProvider) UpdateResource(ctx context.Context, req *UpdateResourceRequest) (*Resource, error)

func (*AWSProvider) ValidateCredentials

func (p *AWSProvider) ValidateCredentials(ctx context.Context) error

ValidateCredentials validates AWS credentials

type AlertInfo

type AlertInfo struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	Status      string    `json:"status"`
	Severity    string    `json:"severity"`
	Description string    `json:"description"`
	Triggered   time.Time `json:"triggered"`
}

AlertInfo represents an alert

type AzureProvider

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

AzureProvider implements the CloudProvider interface for Azure

func (*AzureProvider) Connect

func (p *AzureProvider) Connect(ctx context.Context) error

Connect establishes connection to Azure

func (*AzureProvider) CreateResource

func (p *AzureProvider) CreateResource(ctx context.Context, req *CreateResourceRequest) (*Resource, error)

Additional methods to implement CloudProvider interface

func (*AzureProvider) DeleteResource

func (p *AzureProvider) DeleteResource(ctx context.Context, resourceID string) error

func (*AzureProvider) Disconnect

func (p *AzureProvider) Disconnect(ctx context.Context) error

Disconnect closes the connection

func (*AzureProvider) GetConfiguration

func (p *AzureProvider) GetConfiguration() *ProviderConfig

func (*AzureProvider) GetCost

func (p *AzureProvider) GetCost(ctx context.Context, req *CostRequest) (*CostResponse, error)

func (*AzureProvider) GetMetrics

func (p *AzureProvider) GetMetrics(ctx context.Context, req *MetricsRequest) (*MetricsResponse, error)

func (*AzureProvider) GetName

func (p *AzureProvider) GetName() string

GetName returns the provider name

func (*AzureProvider) GetRegions

func (p *AzureProvider) GetRegions(ctx context.Context) ([]string, error)

func (*AzureProvider) GetResourceDetails

func (p *AzureProvider) GetResourceDetails(ctx context.Context, resourceID string) (*Resource, error)

GetResourceDetails gets detailed information about a resource

func (*AzureProvider) GetResourceTypes

func (p *AzureProvider) GetResourceTypes(ctx context.Context) ([]string, error)

func (*AzureProvider) GetStatus

func (p *AzureProvider) GetStatus() *ProviderStatus

func (*AzureProvider) GetType

func (p *AzureProvider) GetType() string

GetType returns the provider type

func (*AzureProvider) IsConnected

func (p *AzureProvider) IsConnected() bool

IsConnected returns connection status

func (*AzureProvider) ListResources

func (p *AzureProvider) ListResources(ctx context.Context, resourceType string) ([]*Resource, error)

ListResources lists Azure resources

func (*AzureProvider) UpdateConfiguration

func (p *AzureProvider) UpdateConfiguration(config *ProviderConfig) error

func (*AzureProvider) UpdateResource

func (p *AzureProvider) UpdateResource(ctx context.Context, req *UpdateResourceRequest) (*Resource, error)

func (*AzureProvider) ValidateCredentials

func (p *AzureProvider) ValidateCredentials(ctx context.Context) error

ValidateCredentials validates Azure credentials

type BackupInfo

type BackupInfo struct {
	Enabled       bool      `json:"enabled"`
	Schedule      string    `json:"schedule"`
	LastBackup    time.Time `json:"last_backup"`
	NextBackup    time.Time `json:"next_backup"`
	RetentionDays int       `json:"retention_days"`
}

BackupInfo provides backup information

type CloudManager

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

CloudManager manages multiple cloud providers

func NewCloudManager

func NewCloudManager() *CloudManager

NewCloudManager creates a new cloud manager

func (*CloudManager) AddProvider

func (m *CloudManager) AddProvider(provider CloudProvider) error

AddProvider adds a cloud provider to the manager

func (*CloudManager) GetProvider

func (m *CloudManager) GetProvider(name string) (CloudProvider, error)

GetProvider retrieves a cloud provider by name

func (*CloudManager) ListProviders

func (m *CloudManager) ListProviders() []CloudProvider

ListProviders returns a list of all cloud providers

type CloudProvider

type CloudProvider interface {
	GetName() string
	GetType() string
	Connect(ctx context.Context) error
	Disconnect(ctx context.Context) error
	IsConnected() bool
	ListResources(ctx context.Context, resourceType string) ([]*Resource, error)
	GetResourceDetails(ctx context.Context, resourceID string) (*Resource, error)
	CreateResource(ctx context.Context, req *CreateResourceRequest) (*Resource, error)
	UpdateResource(ctx context.Context, req *UpdateResourceRequest) (*Resource, error)
	DeleteResource(ctx context.Context, resourceID string) error
	GetMetrics(ctx context.Context, req *MetricsRequest) (*MetricsResponse, error)
	GetCost(ctx context.Context, req *CostRequest) (*CostResponse, error)
	GetConfiguration() *ProviderConfig
	UpdateConfiguration(config *ProviderConfig) error
	GetStatus() *ProviderStatus
	ValidateCredentials(ctx context.Context) error
	GetRegions(ctx context.Context) ([]string, error)
	GetResourceTypes(ctx context.Context) ([]string, error)
}

CloudProvider interface defines cloud provider operations

func NewAWSProvider

func NewAWSProvider(cfg *ProviderConfig) (CloudProvider, error)

NewAWSProvider creates a new AWS provider

func NewAzureProvider

func NewAzureProvider(cfg *ProviderConfig) (CloudProvider, error)

NewAzureProvider creates a new Azure provider

func NewGCPProvider

func NewGCPProvider(cfg *ProviderConfig) (CloudProvider, error)

NewGCPProvider creates a new GCP provider

type CloudService

type CloudService interface {
	ListResources(ctx context.Context, provider string, resourceType string) ([]Resource, error)
	CreateResource(ctx context.Context, provider string, spec ResourceSpec) (*Resource, error)
	UpdateResource(ctx context.Context, provider string, resourceID string, spec ResourceSpec) (*Resource, error)
	DeleteResource(ctx context.Context, provider string, resourceID string) error
	GetResourceDetails(ctx context.Context, provider string, resourceID string) (*ResourceDetails, error)
	GetCostAnalysis(ctx context.Context, provider string, options CostOptions) (*CostAnalysis, error)
	OptimizeResources(ctx context.Context, provider string, options OptimizeOptions) (*OptimizationResult, error)
	MonitorHealth(ctx context.Context, provider string) (<-chan HealthEvent, error)
}

CloudService interface defines cloud provider operations

func NewCloudService

func NewCloudService(cfg *config.Config) CloudService

NewCloudService creates a new cloud service

type CostAnalysis

type CostAnalysis struct {
	TotalCost       float64              `json:"total_cost"`
	Currency        string               `json:"currency"`
	Period          string               `json:"period"`
	Breakdown       []CostBreakdown      `json:"breakdown"`
	Trends          []CostTrend          `json:"trends"`
	Recommendations []CostRecommendation `json:"recommendations"`
}

CostAnalysis provides cost analysis results

type CostBreakdown

type CostBreakdown struct {
	Category      string  `json:"category"`
	Cost          float64 `json:"cost"`
	Percentage    float64 `json:"percentage"`
	ResourceCount int     `json:"resource_count"`
}

CostBreakdown provides cost breakdown by category

type CostInfo

type CostInfo struct {
	Monthly     float64   `json:"monthly"`
	Daily       float64   `json:"daily"`
	Currency    string    `json:"currency"`
	LastUpdated time.Time `json:"last_updated"`
}

CostInfo provides cost information for a resource

type CostOptions

type CostOptions struct {
	StartDate    time.Time `json:"start_date"`
	EndDate      time.Time `json:"end_date"`
	Granularity  string    `json:"granularity"`
	GroupBy      []string  `json:"group_by"`
	ResourceType string    `json:"resource_type"`
}

CostOptions defines options for cost analysis

type CostPeriod

type CostPeriod struct {
	StartTime time.Time `json:"start_time"`
	EndTime   time.Time `json:"end_time"`
}

CostPeriod represents a cost period

type CostRecommendation

type CostRecommendation struct {
	ID          string   `json:"id"`
	Type        string   `json:"type"`
	Title       string   `json:"title"`
	Description string   `json:"description"`
	Savings     float64  `json:"potential_savings"`
	Effort      string   `json:"effort"`
	Risk        string   `json:"risk"`
	Actions     []string `json:"actions"`
}

CostRecommendation represents a cost optimization recommendation

type CostRequest

type CostRequest struct {
	StartTime time.Time `json:"start_time"`
	EndTime   time.Time `json:"end_time"`
	GroupBy   string    `json:"group_by"`
}

CostRequest represents a request for cost information

type CostResponse

type CostResponse struct {
	Total       float64            `json:"total"`
	Currency    string             `json:"currency"`
	Period      *CostPeriod        `json:"period"`
	BreakdownBy map[string]float64 `json:"breakdown_by"`
}

CostResponse represents a cost response

type CostTrend

type CostTrend struct {
	Date   time.Time `json:"date"`
	Cost   float64   `json:"cost"`
	Change float64   `json:"change"`
}

CostTrend represents cost trend data

type CreateResourceRequest

type CreateResourceRequest struct {
	Type   string                 `json:"type"`
	Name   string                 `json:"name"`
	Region string                 `json:"region"`
	Config map[string]interface{} `json:"config"`
}

CreateResourceRequest represents a request to create a resource

type DefaultCloudService

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

DefaultCloudService provides a default implementation

func (*DefaultCloudService) CreateResource

func (c *DefaultCloudService) CreateResource(ctx context.Context, provider string, spec ResourceSpec) (*Resource, error)

CreateResource creates a new resource

func (*DefaultCloudService) DeleteResource

func (c *DefaultCloudService) DeleteResource(ctx context.Context, provider string, resourceID string) error

DeleteResource deletes a resource

func (*DefaultCloudService) GetCostAnalysis

func (c *DefaultCloudService) GetCostAnalysis(ctx context.Context, provider string, options CostOptions) (*CostAnalysis, error)

GetCostAnalysis provides cost analysis

func (*DefaultCloudService) GetResourceDetails

func (c *DefaultCloudService) GetResourceDetails(ctx context.Context, provider string, resourceID string) (*ResourceDetails, error)

GetResourceDetails gets detailed information about a resource

func (*DefaultCloudService) ListResources

func (c *DefaultCloudService) ListResources(ctx context.Context, provider string, resourceType string) ([]Resource, error)

ListResources lists resources from the specified provider

func (*DefaultCloudService) MonitorHealth

func (c *DefaultCloudService) MonitorHealth(ctx context.Context, provider string) (<-chan HealthEvent, error)

MonitorHealth monitors cloud resource health

func (*DefaultCloudService) OptimizeResources

func (c *DefaultCloudService) OptimizeResources(ctx context.Context, provider string, options OptimizeOptions) (*OptimizationResult, error)

OptimizeResources optimizes cloud resources

func (*DefaultCloudService) UpdateResource

func (c *DefaultCloudService) UpdateResource(ctx context.Context, provider string, resourceID string, spec ResourceSpec) (*Resource, error)

UpdateResource updates an existing resource

type GCPProvider

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

GCPProvider implements the CloudProvider interface for Google Cloud Platform

func (*GCPProvider) Connect

func (p *GCPProvider) Connect(ctx context.Context) error

Connect establishes connection to GCP

func (*GCPProvider) CreateResource

func (p *GCPProvider) CreateResource(ctx context.Context, req *CreateResourceRequest) (*Resource, error)

Additional methods to implement CloudProvider interface

func (*GCPProvider) DeleteResource

func (p *GCPProvider) DeleteResource(ctx context.Context, resourceID string) error

func (*GCPProvider) Disconnect

func (p *GCPProvider) Disconnect(ctx context.Context) error

Disconnect closes the connection

func (*GCPProvider) GetConfiguration

func (p *GCPProvider) GetConfiguration() *ProviderConfig

func (*GCPProvider) GetCost

func (p *GCPProvider) GetCost(ctx context.Context, req *CostRequest) (*CostResponse, error)

func (*GCPProvider) GetMetrics

func (p *GCPProvider) GetMetrics(ctx context.Context, req *MetricsRequest) (*MetricsResponse, error)

func (*GCPProvider) GetName

func (p *GCPProvider) GetName() string

GetName returns the provider name

func (*GCPProvider) GetRegions

func (p *GCPProvider) GetRegions(ctx context.Context) ([]string, error)

func (*GCPProvider) GetResourceDetails

func (p *GCPProvider) GetResourceDetails(ctx context.Context, resourceID string) (*Resource, error)

GetResourceDetails gets detailed information about a resource

func (*GCPProvider) GetResourceTypes

func (p *GCPProvider) GetResourceTypes(ctx context.Context) ([]string, error)

func (*GCPProvider) GetStatus

func (p *GCPProvider) GetStatus() *ProviderStatus

func (*GCPProvider) GetType

func (p *GCPProvider) GetType() string

GetType returns the provider type

func (*GCPProvider) IsConnected

func (p *GCPProvider) IsConnected() bool

IsConnected returns connection status

func (*GCPProvider) ListResources

func (p *GCPProvider) ListResources(ctx context.Context, resourceType string) ([]*Resource, error)

ListResources lists GCP resources

func (*GCPProvider) UpdateConfiguration

func (p *GCPProvider) UpdateConfiguration(config *ProviderConfig) error

func (*GCPProvider) UpdateResource

func (p *GCPProvider) UpdateResource(ctx context.Context, req *UpdateResourceRequest) (*Resource, error)

func (*GCPProvider) ValidateCredentials

func (p *GCPProvider) ValidateCredentials(ctx context.Context) error

ValidateCredentials validates GCP credentials

type HealthEvent

type HealthEvent struct {
	ID         string            `json:"id"`
	Timestamp  time.Time         `json:"timestamp"`
	Provider   string            `json:"provider"`
	ResourceID string            `json:"resource_id"`
	Type       string            `json:"type"`
	Status     string            `json:"status"`
	Message    string            `json:"message"`
	Severity   string            `json:"severity"`
	Details    map[string]string `json:"details"`
}

HealthEvent represents a health monitoring event

type MetricDataPoint

type MetricDataPoint struct {
	Timestamp time.Time `json:"timestamp"`
	Value     float64   `json:"value"`
	Unit      string    `json:"unit"`
}

MetricDataPoint represents a single metric data point

type MetricInfo

type MetricInfo struct {
	Name      string    `json:"name"`
	Value     float64   `json:"value"`
	Unit      string    `json:"unit"`
	Timestamp time.Time `json:"timestamp"`
	Threshold float64   `json:"threshold"`
}

MetricInfo represents a metric

type MetricsRequest

type MetricsRequest struct {
	ResourceID string    `json:"resource_id"`
	MetricName string    `json:"metric_name"`
	StartTime  time.Time `json:"start_time"`
	EndTime    time.Time `json:"end_time"`
	Period     int       `json:"period"`
}

MetricsRequest represents a request for metrics

type MetricsResponse

type MetricsResponse struct {
	MetricName string             `json:"metric_name"`
	DataPoints []*MetricDataPoint `json:"data_points"`
}

MetricsResponse represents a metrics response

type MonitoringInfo

type MonitoringInfo struct {
	Enabled    bool         `json:"enabled"`
	Metrics    []MetricInfo `json:"metrics"`
	Alerts     []AlertInfo  `json:"alerts"`
	Dashboards []string     `json:"dashboards"`
}

MonitoringInfo provides monitoring information

type NetworkInfo

type NetworkInfo struct {
	VPC        string   `json:"vpc"`
	Subnet     string   `json:"subnet"`
	PrivateIPs []string `json:"private_ips"`
	PublicIPs  []string `json:"public_ips"`
	DNS        []string `json:"dns"`
}

NetworkInfo provides network information

type OptimizationRecommendation

type OptimizationRecommendation struct {
	ResourceID  string                 `json:"resource_id"`
	Type        string                 `json:"type"`
	Current     map[string]interface{} `json:"current"`
	Recommended map[string]interface{} `json:"recommended"`
	Savings     float64                `json:"savings"`
	Confidence  float64                `json:"confidence"`
	Actions     []string               `json:"actions"`
}

OptimizationRecommendation represents an optimization recommendation

type OptimizationResult

type OptimizationResult struct {
	ID               string                       `json:"id"`
	Timestamp        time.Time                    `json:"timestamp"`
	Status           string                       `json:"status"`
	Recommendations  []OptimizationRecommendation `json:"recommendations"`
	PotentialSavings float64                      `json:"potential_savings"`
	RiskAssessment   string                       `json:"risk_assessment"`
}

OptimizationResult provides optimization results

type OptimizeOptions

type OptimizeOptions struct {
	ResourceTypes []string `json:"resource_types"`
	Criteria      []string `json:"criteria"`
	DryRun        bool     `json:"dry_run"`
}

OptimizeOptions defines options for resource optimization

type ProviderConfig

type ProviderConfig struct {
	Region      string            `json:"region"`
	Credentials map[string]string `json:"credentials"`
	// AWS specific
	Profile string `json:"profile,omitempty"`
	// Azure specific
	SubscriptionID string `json:"subscription_id,omitempty"`
	TenantID       string `json:"tenant_id,omitempty"`
	// GCP specific
	ProjectID          string `json:"project_id,omitempty"`
	ServiceAccountPath string `json:"service_account_path,omitempty"`
}

ProviderConfig represents cloud provider configuration

type ProviderStatus

type ProviderStatus struct {
	Name      string    `json:"name"`
	Type      string    `json:"type"`
	Status    string    `json:"status"`
	Connected bool      `json:"connected"`
	LastCheck time.Time `json:"last_check"`
	Health    string    `json:"health"`
}

ProviderStatus represents cloud provider status

type Resource

type Resource struct {
	ID        string                 `json:"id"`
	Name      string                 `json:"name"`
	Type      string                 `json:"type"`
	Provider  string                 `json:"provider"`
	Region    string                 `json:"region"`
	State     string                 `json:"state"`
	Status    string                 `json:"status"`
	Config    map[string]interface{} `json:"config"`
	CreatedAt time.Time              `json:"created_at"`
	Created   time.Time              `json:"created"`
	Modified  time.Time              `json:"modified"`
	Tags      map[string]string      `json:"tags"`
	Metadata  map[string]string      `json:"metadata"`
	Cost      *CostInfo              `json:"cost,omitempty"`
}

Resource represents a cloud resource

type ResourceDetails

type ResourceDetails struct {
	Resource       Resource               `json:"resource"`
	Configuration  map[string]interface{} `json:"configuration"`
	Dependencies   []string               `json:"dependencies"`
	SecurityGroups []SecurityGroup        `json:"security_groups"`
	NetworkInfo    NetworkInfo            `json:"network_info"`
	Monitoring     MonitoringInfo         `json:"monitoring"`
	Backup         BackupInfo             `json:"backup"`
}

ResourceDetails provides detailed information about a resource

type ResourceSpec

type ResourceSpec struct {
	Name          string                 `json:"name"`
	Type          string                 `json:"type"`
	Region        string                 `json:"region"`
	Configuration map[string]interface{} `json:"configuration"`
	Tags          map[string]string      `json:"tags"`
}

ResourceSpec defines the specification for creating/updating resources

type SecurityGroup

type SecurityGroup struct {
	ID          string              `json:"id"`
	Name        string              `json:"name"`
	Description string              `json:"description"`
	Rules       []SecurityGroupRule `json:"rules"`
}

SecurityGroup represents a security group

type SecurityGroupRule

type SecurityGroupRule struct {
	Protocol  string `json:"protocol"`
	Port      string `json:"port"`
	Source    string `json:"source"`
	Direction string `json:"direction"`
	Action    string `json:"action"`
}

SecurityGroupRule represents a security group rule

type UpdateResourceRequest

type UpdateResourceRequest struct {
	ID     string                 `json:"id"`
	Config map[string]interface{} `json:"config"`
}

UpdateResourceRequest represents a request to update a resource

Jump to

Keyboard shortcuts

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