quantrs2_device/cloud/orchestration/
mod.rs

1//! Cloud Orchestration and Load Balancing Configuration
2//!
3//! This module provides comprehensive configuration structures for cloud orchestration,
4//! including performance optimization, load balancing, security, and budget management.
5//!
6//! The module is organized into focused sub-modules for better maintainability:
7//! - `performance`: Performance optimization and QoS configurations
8//! - `load_balancing`: Load balancing and traffic management
9//! - `security`: Security, authentication, and compliance
10//! - `budget`: Budget management and cost tracking
11//! - `defaults`: Default implementations for all configurations
12
13pub mod load_balancing;
14pub mod performance;
15
16// TODO: Create dedicated modules for security and budget
17// pub mod security;
18// pub mod budget;
19// pub mod defaults;
20
21// Re-export all types for backward compatibility
22pub use load_balancing::*;
23pub use performance::*;
24
25// Note: security and budget modules need to be created
26// For now, we'll need to keep the remaining types in this file temporarily
27
28use serde::{Deserialize, Serialize};
29use std::collections::HashMap;
30use std::time::Duration;
31
32/// Cloud security configuration
33#[derive(Debug, Clone, Serialize, Deserialize)]
34pub struct CloudSecurityConfig {
35    /// Authentication configuration
36    pub authentication: AuthenticationConfig,
37    /// Authorization configuration
38    pub authorization: AuthorizationConfig,
39    /// Encryption configuration
40    pub encryption: EncryptionConfig,
41    /// Network security
42    pub network_security: NetworkSecurityConfig,
43    /// Compliance configuration
44    pub compliance: ComplianceConfig,
45}
46
47// Include all the security-related types temporarily
48/// Authentication configuration
49#[derive(Debug, Clone, Serialize, Deserialize)]
50pub struct AuthenticationConfig {
51    /// Authentication methods
52    pub methods: Vec<AuthMethod>,
53    /// Multi-factor authentication
54    pub mfa: MFAConfig,
55    /// Single sign-on
56    pub sso: SSOConfig,
57}
58
59/// Authentication methods
60#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
61pub enum AuthMethod {
62    Password,
63    APIKey,
64    Certificate,
65    OAuth2,
66    SAML,
67    Custom(String),
68}
69
70/// MFA configuration
71#[derive(Debug, Clone, Serialize, Deserialize)]
72pub struct MFAConfig {
73    /// Enable MFA
74    pub enabled: bool,
75    /// MFA methods
76    pub methods: Vec<MFAMethod>,
77    /// Backup codes
78    pub backup_codes: bool,
79}
80
81/// MFA methods
82#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
83pub enum MFAMethod {
84    TOTP,
85    SMS,
86    Email,
87    PushNotification,
88    Hardware,
89}
90
91/// SSO configuration
92#[derive(Debug, Clone, Serialize, Deserialize)]
93pub struct SSOConfig {
94    /// Enable SSO
95    pub enabled: bool,
96    /// SSO provider
97    pub provider: SSOProvider,
98    /// SAML configuration
99    pub saml: SAMLConfig,
100    /// OIDC configuration
101    pub oidc: OIDCConfig,
102}
103
104/// SSO providers
105#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
106pub enum SSOProvider {
107    SAML,
108    OIDC,
109    LDAP,
110    ActiveDirectory,
111    Custom(String),
112}
113
114/// SAML configuration
115#[derive(Debug, Clone, Serialize, Deserialize)]
116pub struct SAMLConfig {
117    /// Identity provider URL
118    pub idp_url: String,
119    /// Service provider ID
120    pub sp_id: String,
121    /// Certificate
122    pub certificate: String,
123}
124
125/// OIDC configuration
126#[derive(Debug, Clone, Serialize, Deserialize)]
127pub struct OIDCConfig {
128    /// Client ID
129    pub client_id: String,
130    /// Client secret
131    pub client_secret: String,
132    /// Discovery URL
133    pub discovery_url: String,
134}
135
136/// Authorization configuration
137#[derive(Debug, Clone, Serialize, Deserialize)]
138pub struct AuthorizationConfig {
139    /// Authorization model
140    pub model: AuthorizationModel,
141    /// Role definitions
142    pub roles: Vec<RoleDefinition>,
143    /// Permission system
144    pub permissions: PermissionSystem,
145}
146
147/// Authorization models
148#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
149pub enum AuthorizationModel {
150    RBAC,
151    ABAC,
152    DAC,
153    MAC,
154    Custom(String),
155}
156
157/// Role definition
158#[derive(Debug, Clone, Serialize, Deserialize)]
159pub struct RoleDefinition {
160    /// Role name
161    pub name: String,
162    /// Description
163    pub description: String,
164    /// Permissions
165    pub permissions: Vec<String>,
166    /// Role hierarchy
167    pub parent_roles: Vec<String>,
168}
169
170/// Permission system
171#[derive(Debug, Clone, Serialize, Deserialize)]
172pub struct PermissionSystem {
173    /// Permission model
174    pub model: PermissionModel,
175    /// Resource definitions
176    pub resources: Vec<ResourceDefinition>,
177    /// Action definitions
178    pub actions: Vec<ActionDefinition>,
179}
180
181/// Permission models
182#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
183pub enum PermissionModel {
184    ResourceAction,
185    CapabilityBased,
186    AttributeBased,
187    Custom(String),
188}
189
190/// Resource definition
191#[derive(Debug, Clone, Serialize, Deserialize)]
192pub struct ResourceDefinition {
193    /// Resource type
194    pub resource_type: String,
195    /// Resource attributes
196    pub attributes: HashMap<String, String>,
197    /// Access patterns
198    pub access_patterns: Vec<AccessPattern>,
199}
200
201/// Access pattern
202#[derive(Debug, Clone, Serialize, Deserialize)]
203pub struct AccessPattern {
204    /// Pattern name
205    pub name: String,
206    /// Allowed actions
207    pub actions: Vec<String>,
208    /// Conditions
209    pub conditions: Vec<AccessCondition>,
210}
211
212/// Access condition
213#[derive(Debug, Clone, Serialize, Deserialize)]
214pub struct AccessCondition {
215    /// Attribute
216    pub attribute: String,
217    /// Operator
218    pub operator: String,
219    /// Value
220    pub value: String,
221}
222
223/// Action definition
224#[derive(Debug, Clone, Serialize, Deserialize)]
225pub struct ActionDefinition {
226    /// Action name
227    pub name: String,
228    /// Description
229    pub description: String,
230    /// Required permissions
231    pub required_permissions: Vec<String>,
232}
233
234/// Encryption configuration
235#[derive(Debug, Clone, Serialize, Deserialize)]
236pub struct EncryptionConfig {
237    /// Encryption at rest
238    pub at_rest: EncryptionAtRestConfig,
239    /// Encryption in transit
240    pub in_transit: EncryptionInTransitConfig,
241    /// Key management
242    pub key_management: EncryptionKeyManagementConfig,
243}
244
245/// Encryption at rest configuration
246#[derive(Debug, Clone, Serialize, Deserialize)]
247pub struct EncryptionAtRestConfig {
248    /// Enable encryption
249    pub enabled: bool,
250    /// Encryption algorithm
251    pub algorithm: String,
252    /// Key size
253    pub key_size: usize,
254}
255
256/// Encryption in transit configuration
257#[derive(Debug, Clone, Serialize, Deserialize)]
258pub struct EncryptionInTransitConfig {
259    /// Enable encryption
260    pub enabled: bool,
261    /// TLS version
262    pub tls_version: String,
263    /// Cipher suites
264    pub cipher_suites: Vec<String>,
265}
266
267/// Encryption key management configuration
268#[derive(Debug, Clone, Serialize, Deserialize)]
269pub struct EncryptionKeyManagementConfig {
270    /// Key management service
271    pub service: KeyManagementService,
272    /// Key rotation policy
273    pub rotation_policy: EncryptionKeyRotationPolicy,
274    /// Key backup policy
275    pub backup_policy: EncryptionKeyBackupPolicy,
276}
277
278/// Key management services
279#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
280pub enum KeyManagementService {
281    AwsKms,
282    AzureKeyVault,
283    GoogleKms,
284    HashiCorpVault,
285    Custom(String),
286}
287
288/// Key rotation policy
289#[derive(Debug, Clone, Serialize, Deserialize)]
290pub struct EncryptionKeyRotationPolicy {
291    /// Enable rotation
292    pub enabled: bool,
293    /// Rotation frequency
294    pub frequency: Duration,
295    /// Automatic rotation
296    pub automatic: bool,
297}
298
299/// Key backup policy
300#[derive(Debug, Clone, Serialize, Deserialize)]
301pub struct EncryptionKeyBackupPolicy {
302    /// Enable backup
303    pub enabled: bool,
304    /// Backup frequency
305    pub frequency: Duration,
306    /// Backup locations
307    pub locations: Vec<String>,
308}
309
310/// Network security configuration
311#[derive(Debug, Clone, Serialize, Deserialize)]
312pub struct NetworkSecurityConfig {
313    /// Firewall configuration
314    pub firewall: FirewallConfig,
315    /// VPN configuration
316    pub vpn: VPNConfig,
317    /// DDoS protection
318    pub ddos_protection: DDoSProtectionConfig,
319}
320
321/// Firewall configuration
322#[derive(Debug, Clone, Serialize, Deserialize)]
323pub struct FirewallConfig {
324    /// Enable firewall
325    pub enabled: bool,
326    /// Firewall rules
327    pub rules: Vec<FirewallRule>,
328    /// Default policy
329    pub default_policy: FirewallPolicy,
330}
331
332/// Firewall rule
333#[derive(Debug, Clone, Serialize, Deserialize)]
334pub struct FirewallRule {
335    /// Rule name
336    pub name: String,
337    /// Source
338    pub source: String,
339    /// Destination
340    pub destination: String,
341    /// Port
342    pub port: String,
343    /// Protocol
344    pub protocol: String,
345    /// Action
346    pub action: FirewallAction,
347}
348
349/// Firewall policies
350#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
351pub enum FirewallPolicy {
352    Allow,
353    Deny,
354    Log,
355}
356
357/// Firewall actions
358#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
359pub enum FirewallAction {
360    Allow,
361    Deny,
362    Log,
363}
364
365/// VPN configuration
366#[derive(Debug, Clone, Serialize, Deserialize)]
367pub struct VPNConfig {
368    /// Enable VPN
369    pub enabled: bool,
370    /// VPN type
371    pub vpn_type: VPNType,
372    /// Connection settings
373    pub connection: VPNConnectionConfig,
374}
375
376/// VPN types
377#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
378pub enum VPNType {
379    SiteToSite,
380    PointToSite,
381    PointToPoint,
382    Custom(String),
383}
384
385/// VPN connection configuration
386#[derive(Debug, Clone, Serialize, Deserialize)]
387pub struct VPNConnectionConfig {
388    /// Gateway address
389    pub gateway: String,
390    /// Pre-shared key
391    pub psk: String,
392    /// Encryption
393    pub encryption: String,
394}
395
396/// DDoS protection configuration
397#[derive(Debug, Clone, Serialize, Deserialize)]
398pub struct DDoSProtectionConfig {
399    /// Enable protection
400    pub enabled: bool,
401    /// Protection level
402    pub level: DDoSProtectionLevel,
403    /// Rate limiting
404    pub rate_limiting: RateLimitingConfig,
405}
406
407/// DDoS protection levels
408#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
409pub enum DDoSProtectionLevel {
410    Basic,
411    Standard,
412    Premium,
413    Custom(String),
414}
415
416/// Rate limiting configuration
417#[derive(Debug, Clone, Serialize, Deserialize)]
418pub struct RateLimitingConfig {
419    /// Enable rate limiting
420    pub enabled: bool,
421    /// Request limits
422    pub limits: HashMap<String, usize>,
423    /// Time windows
424    pub windows: HashMap<String, Duration>,
425}
426
427/// Compliance configuration
428#[derive(Debug, Clone, Serialize, Deserialize)]
429pub struct ComplianceConfig {
430    /// Compliance frameworks
431    pub frameworks: Vec<ComplianceFramework>,
432    /// Audit configuration
433    pub audit: AuditConfig,
434    /// Data governance
435    pub data_governance: DataGovernanceConfig,
436}
437
438/// Compliance frameworks
439#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
440pub enum ComplianceFramework {
441    SOC2,
442    ISO27001,
443    GDPR,
444    HIPAA,
445    PciDss,
446    Custom(String),
447}
448
449/// Audit configuration
450#[derive(Debug, Clone, Serialize, Deserialize)]
451pub struct AuditConfig {
452    /// Enable auditing
453    pub enabled: bool,
454    /// Audit events
455    pub events: Vec<AuditEvent>,
456    /// Log retention
457    pub retention: Duration,
458}
459
460/// Audit events
461#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
462pub enum AuditEvent {
463    Authentication,
464    Authorization,
465    DataAccess,
466    ConfigChange,
467    SecurityEvent,
468    Custom(String),
469}
470
471/// Data governance configuration
472#[derive(Debug, Clone, Serialize, Deserialize)]
473pub struct DataGovernanceConfig {
474    /// Data classification
475    pub classification: DataClassificationConfig,
476    /// Data retention
477    pub retention: DataRetentionConfig,
478    /// Data privacy
479    pub privacy: DataPrivacyConfig,
480}
481
482/// Data classification configuration
483#[derive(Debug, Clone, Serialize, Deserialize)]
484pub struct DataClassificationConfig {
485    /// Classification levels
486    pub levels: Vec<ClassificationLevel>,
487    /// Auto-classification
488    pub auto_classification: bool,
489}
490
491/// Classification level
492#[derive(Debug, Clone, Serialize, Deserialize)]
493pub struct ClassificationLevel {
494    /// Level name
495    pub name: String,
496    /// Sensitivity score
497    pub sensitivity: u8,
498    /// Handling requirements
499    pub requirements: Vec<String>,
500}
501
502/// Data retention configuration
503#[derive(Debug, Clone, Serialize, Deserialize)]
504pub struct DataRetentionConfig {
505    /// Retention policies
506    pub policies: Vec<RetentionPolicy>,
507    /// Default retention
508    pub default_retention: Duration,
509}
510
511/// Retention policy
512#[derive(Debug, Clone, Serialize, Deserialize)]
513pub struct RetentionPolicy {
514    /// Data type
515    pub data_type: String,
516    /// Retention period
517    pub retention_period: Duration,
518    /// Disposal method
519    pub disposal_method: DisposalMethod,
520}
521
522/// Disposal methods
523#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
524pub enum DisposalMethod {
525    Delete,
526    Archive,
527    Anonymize,
528    Custom(String),
529}
530
531/// Data privacy configuration
532#[derive(Debug, Clone, Serialize, Deserialize)]
533pub struct DataPrivacyConfig {
534    /// Privacy controls
535    pub controls: Vec<PrivacyControl>,
536    /// Consent management
537    pub consent: ConsentManagementConfig,
538}
539
540/// Privacy controls
541#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
542pub enum PrivacyControl {
543    Anonymization,
544    Pseudonymization,
545    DataMinimization,
546    AccessControl,
547    Custom(String),
548}
549
550/// Consent management configuration
551#[derive(Debug, Clone, Serialize, Deserialize)]
552pub struct ConsentManagementConfig {
553    /// Enable consent management
554    pub enabled: bool,
555    /// Consent types
556    pub consent_types: Vec<String>,
557    /// Withdrawal process
558    pub withdrawal_process: WithdrawalProcess,
559}
560
561/// Withdrawal process
562#[derive(Debug, Clone, Serialize, Deserialize)]
563pub struct WithdrawalProcess {
564    /// Methods available
565    pub methods: Vec<WithdrawalMethod>,
566    /// Processing time
567    pub processing_time: Duration,
568    /// Confirmation required
569    pub confirmation_required: bool,
570}
571
572/// Withdrawal methods
573#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
574pub enum WithdrawalMethod {
575    Online,
576    Email,
577    Phone,
578    Mail,
579    Custom(String),
580}
581
582/// Budget management configuration
583#[derive(Debug, Clone, Serialize, Deserialize)]
584pub struct BudgetManagementConfig {
585    /// Global budget settings
586    pub global_budget: GlobalBudgetConfig,
587    /// Department budgets
588    pub department_budgets: HashMap<String, DepartmentBudgetConfig>,
589    /// Project budgets
590    pub project_budgets: HashMap<String, ProjectBudgetConfig>,
591    /// Budget monitoring
592    pub monitoring: BudgetMonitoringConfig,
593}
594
595/// Global budget configuration
596#[derive(Debug, Clone, Serialize, Deserialize)]
597pub struct GlobalBudgetConfig {
598    /// Total budget
599    pub total_budget: f64,
600    /// Budget period
601    pub period: BudgetPeriod,
602    /// Currency
603    pub currency: String,
604    /// Rollover policy
605    pub rollover_policy: RolloverPolicy,
606}
607
608/// Budget periods
609#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
610pub enum BudgetPeriod {
611    Monthly,
612    Quarterly,
613    Annual,
614    Custom(Duration),
615}
616
617/// Rollover policies
618#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
619pub enum RolloverPolicy {
620    NoRollover,
621    FullRollover,
622    PartialRollover(f64),
623    ConditionalRollover,
624}
625
626/// Department budget configuration
627#[derive(Debug, Clone, Serialize, Deserialize)]
628pub struct DepartmentBudgetConfig {
629    /// Department name
630    pub name: String,
631    /// Allocated budget
632    pub allocated_budget: f64,
633    /// Spending limits
634    pub spending_limits: SpendingLimits,
635    /// Approval workflow
636    pub approval_workflow: BudgetApprovalWorkflow,
637}
638
639/// Spending limits
640#[derive(Debug, Clone, Serialize, Deserialize)]
641pub struct SpendingLimits {
642    /// Daily limit
643    pub daily_limit: Option<f64>,
644    /// Weekly limit
645    pub weekly_limit: Option<f64>,
646    /// Monthly limit
647    pub monthly_limit: Option<f64>,
648    /// Per-transaction limit
649    pub per_transaction_limit: Option<f64>,
650}
651
652/// Budget approval workflow
653#[derive(Debug, Clone, Serialize, Deserialize)]
654pub struct BudgetApprovalWorkflow {
655    /// Approval levels
656    pub levels: Vec<BudgetApprovalLevel>,
657    /// Auto-approval thresholds
658    pub auto_approval_thresholds: HashMap<String, f64>,
659    /// Escalation timeouts
660    pub escalation_timeouts: HashMap<String, Duration>,
661}
662
663/// Budget approval level
664#[derive(Debug, Clone, Serialize, Deserialize)]
665pub struct BudgetApprovalLevel {
666    /// Level name
667    pub name: String,
668    /// Approvers
669    pub approvers: Vec<String>,
670    /// Spending thresholds
671    pub thresholds: HashMap<String, f64>,
672}
673
674/// Project budget configuration
675#[derive(Debug, Clone, Serialize, Deserialize)]
676pub struct ProjectBudgetConfig {
677    /// Project name
678    pub name: String,
679    /// Project budget
680    pub budget: f64,
681    /// Cost tracking
682    pub cost_tracking: ProjectCostTracking,
683    /// Budget alerts
684    pub alerts: ProjectBudgetAlerts,
685}
686
687/// Project cost tracking
688#[derive(Debug, Clone, Serialize, Deserialize)]
689pub struct ProjectCostTracking {
690    /// Granularity
691    pub granularity: CostTrackingGranularity,
692    /// Cost categories
693    pub categories: Vec<CostCategory>,
694    /// Allocation rules
695    pub allocation_rules: Vec<CostAllocationRule>,
696}
697
698/// Cost tracking granularity
699#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
700pub enum CostTrackingGranularity {
701    Hourly,
702    Daily,
703    Weekly,
704    Monthly,
705}
706
707/// Cost category
708#[derive(Debug, Clone, Serialize, Deserialize)]
709pub struct CostCategory {
710    /// Category name
711    pub name: String,
712    /// Description
713    pub description: String,
714    /// Budget allocation
715    pub budget_allocation: f64,
716}
717
718/// Cost allocation rule
719#[derive(Debug, Clone, Serialize, Deserialize)]
720pub struct CostAllocationRule {
721    /// Rule name
722    pub name: String,
723    /// Source category
724    pub source: String,
725    /// Target category
726    pub target: String,
727    /// Allocation percentage
728    pub percentage: f64,
729}
730
731/// Project budget alerts
732#[derive(Debug, Clone, Serialize, Deserialize)]
733pub struct ProjectBudgetAlerts {
734    /// Alert thresholds
735    pub thresholds: Vec<f64>,
736    /// Alert recipients
737    pub recipients: Vec<String>,
738    /// Alert frequency
739    pub frequency: AlertFrequency,
740}
741
742/// Alert frequency
743#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
744pub enum AlertFrequency {
745    Immediate,
746    Daily,
747    Weekly,
748    OnThreshold,
749}
750
751/// Budget monitoring configuration
752#[derive(Debug, Clone, Serialize, Deserialize)]
753pub struct BudgetMonitoringConfig {
754    /// Real-time monitoring
755    pub real_time: bool,
756    /// Reporting frequency
757    pub reporting_frequency: ReportingFrequency,
758    /// Variance analysis
759    pub variance_analysis: BudgetVarianceAnalysis,
760    /// Forecasting
761    pub forecasting: BudgetForecastingConfig,
762}
763
764/// Reporting frequency
765#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
766pub enum ReportingFrequency {
767    RealTime,
768    Hourly,
769    Daily,
770    Weekly,
771    Monthly,
772}
773
774/// Budget variance analysis
775#[derive(Debug, Clone, Serialize, Deserialize)]
776pub struct BudgetVarianceAnalysis {
777    /// Enable analysis
778    pub enabled: bool,
779    /// Variance thresholds
780    pub thresholds: BudgetVarianceThresholds,
781    /// Analysis methods
782    pub methods: Vec<VarianceAnalysisMethod>,
783}
784
785/// Budget variance thresholds
786#[derive(Debug, Clone, Serialize, Deserialize)]
787pub struct BudgetVarianceThresholds {
788    /// Warning threshold
789    pub warning: f64,
790    /// Critical threshold
791    pub critical: f64,
792    /// Emergency threshold
793    pub emergency: f64,
794}
795
796/// Variance analysis methods
797#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
798pub enum VarianceAnalysisMethod {
799    AbsoluteVariance,
800    PercentageVariance,
801    TrendAnalysis,
802    SeasonalAnalysis,
803}
804
805/// Budget forecasting configuration
806#[derive(Debug, Clone, Serialize, Deserialize)]
807pub struct BudgetForecastingConfig {
808    /// Enable forecasting
809    pub enabled: bool,
810    /// Forecasting models
811    pub models: Vec<BudgetForecastingModel>,
812    /// Forecast horizon
813    pub horizon: Duration,
814    /// Update frequency
815    pub update_frequency: Duration,
816}
817
818/// Budget forecasting models
819#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
820pub enum BudgetForecastingModel {
821    LinearTrend,
822    ExponentialSmoothing,
823    ARIMA,
824    MachineLearning,
825    Custom(String),
826}