use candid::Principal;
use canic_contracts::ids::{
CanisterRole, ComponentBinding, ComponentInstanceId, ComponentSpecId, FleetSubnetRootBinding,
FleetSubnetRootReleaseSet,
};
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct ComponentAuthorityRecord {
pub environment: String,
pub fleet: String,
pub root_name: String,
pub source_plan_sha256: String,
pub binding: FleetSubnetRootBinding,
pub release_set: FleetSubnetRootReleaseSet,
pub root_module_sha256: String,
pub root_candid_sha256: [u8; 32],
pub root_controllers: Vec<String>,
pub registry_sha256: [u8; 32],
pub operator: Principal,
pub component_spec: ComponentSpecId,
pub spec_hash: [u8; 32],
pub role: CanisterRole,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct ComponentPlanRecord {
pub schema_version: u16,
pub name: String,
pub operation_id: [u8; 32],
pub authority: ComponentAuthorityRecord,
pub review_sha256: String,
}
#[derive(Clone, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum ComponentPhase {
Reserved,
CreationIntent,
Created,
InstallIntent,
Installed,
Verified,
Committed,
Removed,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct ComponentProgressRecord {
pub allocation_sequence: u64,
pub component: ComponentInstanceId,
pub phase: ComponentPhase,
pub binding: Option<ComponentBinding>,
pub complete: bool,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct ComponentOperationRecord {
pub document_sha256: String,
pub plan: ComponentPlanRecord,
pub submission_attempts: u64,
pub progress: Option<ComponentProgressRecord>,
}