Skip to main content

quantrs2_device/cloud/orchestration/
budget.rs

1//! Cloud Orchestration — Budget Management Configuration
2//!
3//! Budget tracking, approval workflows, cost allocation, monitoring,
4//! and forecasting configuration types for cloud orchestration.
5
6use serde::{Deserialize, Serialize};
7use std::collections::HashMap;
8use std::time::Duration;
9
10/// Budget management configuration
11#[derive(Debug, Clone, Serialize, Deserialize)]
12pub struct BudgetManagementConfig {
13    /// Global budget settings
14    pub global_budget: GlobalBudgetConfig,
15    /// Department budgets
16    pub department_budgets: HashMap<String, DepartmentBudgetConfig>,
17    /// Project budgets
18    pub project_budgets: HashMap<String, ProjectBudgetConfig>,
19    /// Budget monitoring
20    pub monitoring: BudgetMonitoringConfig,
21}
22
23/// Global budget configuration
24#[derive(Debug, Clone, Serialize, Deserialize)]
25pub struct GlobalBudgetConfig {
26    /// Total budget
27    pub total_budget: f64,
28    /// Budget period
29    pub period: BudgetPeriod,
30    /// Currency
31    pub currency: String,
32    /// Rollover policy
33    pub rollover_policy: RolloverPolicy,
34}
35
36/// Budget periods
37#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
38pub enum BudgetPeriod {
39    Monthly,
40    Quarterly,
41    Annual,
42    Custom(Duration),
43}
44
45/// Rollover policies
46#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
47pub enum RolloverPolicy {
48    NoRollover,
49    FullRollover,
50    PartialRollover(f64),
51    ConditionalRollover,
52}
53
54/// Department budget configuration
55#[derive(Debug, Clone, Serialize, Deserialize)]
56pub struct DepartmentBudgetConfig {
57    /// Department name
58    pub name: String,
59    /// Allocated budget
60    pub allocated_budget: f64,
61    /// Spending limits
62    pub spending_limits: SpendingLimits,
63    /// Approval workflow
64    pub approval_workflow: BudgetApprovalWorkflow,
65}
66
67/// Spending limits
68#[derive(Debug, Clone, Serialize, Deserialize)]
69pub struct SpendingLimits {
70    /// Daily limit
71    pub daily_limit: Option<f64>,
72    /// Weekly limit
73    pub weekly_limit: Option<f64>,
74    /// Monthly limit
75    pub monthly_limit: Option<f64>,
76    /// Per-transaction limit
77    pub per_transaction_limit: Option<f64>,
78}
79
80/// Budget approval workflow
81#[derive(Debug, Clone, Serialize, Deserialize)]
82pub struct BudgetApprovalWorkflow {
83    /// Approval levels
84    pub levels: Vec<BudgetApprovalLevel>,
85    /// Auto-approval thresholds
86    pub auto_approval_thresholds: HashMap<String, f64>,
87    /// Escalation timeouts
88    pub escalation_timeouts: HashMap<String, Duration>,
89}
90
91/// Budget approval level
92#[derive(Debug, Clone, Serialize, Deserialize)]
93pub struct BudgetApprovalLevel {
94    /// Level name
95    pub name: String,
96    /// Approvers
97    pub approvers: Vec<String>,
98    /// Spending thresholds
99    pub thresholds: HashMap<String, f64>,
100}
101
102/// Project budget configuration
103#[derive(Debug, Clone, Serialize, Deserialize)]
104pub struct ProjectBudgetConfig {
105    /// Project name
106    pub name: String,
107    /// Project budget
108    pub budget: f64,
109    /// Cost tracking
110    pub cost_tracking: ProjectCostTracking,
111    /// Budget alerts
112    pub alerts: ProjectBudgetAlerts,
113}
114
115/// Project cost tracking
116#[derive(Debug, Clone, Serialize, Deserialize)]
117pub struct ProjectCostTracking {
118    /// Granularity
119    pub granularity: CostTrackingGranularity,
120    /// Cost categories
121    pub categories: Vec<CostCategory>,
122    /// Allocation rules
123    pub allocation_rules: Vec<CostAllocationRule>,
124}
125
126/// Cost tracking granularity
127#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
128pub enum CostTrackingGranularity {
129    Hourly,
130    Daily,
131    Weekly,
132    Monthly,
133}
134
135/// Cost category
136#[derive(Debug, Clone, Serialize, Deserialize)]
137pub struct CostCategory {
138    /// Category name
139    pub name: String,
140    /// Description
141    pub description: String,
142    /// Budget allocation
143    pub budget_allocation: f64,
144}
145
146/// Cost allocation rule
147#[derive(Debug, Clone, Serialize, Deserialize)]
148pub struct CostAllocationRule {
149    /// Rule name
150    pub name: String,
151    /// Source category
152    pub source: String,
153    /// Target category
154    pub target: String,
155    /// Allocation percentage
156    pub percentage: f64,
157}
158
159/// Project budget alerts
160#[derive(Debug, Clone, Serialize, Deserialize)]
161pub struct ProjectBudgetAlerts {
162    /// Alert thresholds
163    pub thresholds: Vec<f64>,
164    /// Alert recipients
165    pub recipients: Vec<String>,
166    /// Alert frequency
167    pub frequency: AlertFrequency,
168}
169
170/// Alert frequency
171#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
172pub enum AlertFrequency {
173    Immediate,
174    Daily,
175    Weekly,
176    OnThreshold,
177}
178
179/// Budget monitoring configuration
180#[derive(Debug, Clone, Serialize, Deserialize)]
181pub struct BudgetMonitoringConfig {
182    /// Real-time monitoring
183    pub real_time: bool,
184    /// Reporting frequency
185    pub reporting_frequency: ReportingFrequency,
186    /// Variance analysis
187    pub variance_analysis: BudgetVarianceAnalysis,
188    /// Forecasting
189    pub forecasting: BudgetForecastingConfig,
190}
191
192/// Reporting frequency
193#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
194pub enum ReportingFrequency {
195    RealTime,
196    Hourly,
197    Daily,
198    Weekly,
199    Monthly,
200}
201
202/// Budget variance analysis
203#[derive(Debug, Clone, Serialize, Deserialize)]
204pub struct BudgetVarianceAnalysis {
205    /// Enable analysis
206    pub enabled: bool,
207    /// Variance thresholds
208    pub thresholds: BudgetVarianceThresholds,
209    /// Analysis methods
210    pub methods: Vec<VarianceAnalysisMethod>,
211}
212
213/// Budget variance thresholds
214#[derive(Debug, Clone, Serialize, Deserialize)]
215pub struct BudgetVarianceThresholds {
216    /// Warning threshold
217    pub warning: f64,
218    /// Critical threshold
219    pub critical: f64,
220    /// Emergency threshold
221    pub emergency: f64,
222}
223
224/// Variance analysis methods
225#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
226pub enum VarianceAnalysisMethod {
227    AbsoluteVariance,
228    PercentageVariance,
229    TrendAnalysis,
230    SeasonalAnalysis,
231}
232
233/// Budget forecasting configuration
234#[derive(Debug, Clone, Serialize, Deserialize)]
235pub struct BudgetForecastingConfig {
236    /// Enable forecasting
237    pub enabled: bool,
238    /// Forecasting models
239    pub models: Vec<BudgetForecastingModel>,
240    /// Forecast horizon
241    pub horizon: Duration,
242    /// Update frequency
243    pub update_frequency: Duration,
244}
245
246/// Budget forecasting models
247#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
248pub enum BudgetForecastingModel {
249    LinearTrend,
250    ExponentialSmoothing,
251    ARIMA,
252    MachineLearning,
253    Custom(String),
254}