use serde::Serialize;

#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct BundleManifest {
    #[serde(rename = "schemaVersion")]
    pub schema_version: String,
    #[serde(rename = "bundleProducer")]
    pub bundle_producer: String,
    #[serde(rename = "recordedAt")]
    pub recorded_at_rfc3339_utc: String,
    pub rirs: Vec<String>,
    #[serde(rename = "perRirBundles")]
    pub per_rir_bundles: Vec<BundleManifestEntry>,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct BundleManifestEntry {
    pub rir: String,
    pub relative_path: String,
    #[serde(rename = "baseValidationTime")]
    pub base_validation_time: String,
    #[serde(rename = "deltaValidationTime", skip_serializing_if = "Option::is_none")]
    pub delta_validation_time: Option<String>,
    #[serde(rename = "hasAspa")]
    pub has_aspa: bool,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct RirBundleMetadata {
    #[serde(rename = "schemaVersion")]
    pub schema_version: String,
    #[serde(rename = "bundleProducer")]
    pub bundle_producer: String,
    pub rir: String,
    #[serde(rename = "baseValidationTime")]
    pub base_validation_time: String,
    #[serde(rename = "deltaValidationTime", skip_serializing_if = "Option::is_none")]
    pub delta_validation_time: Option<String>,
    #[serde(rename = "talSha256")]
    pub tal_sha256: String,
    #[serde(rename = "taCertSha256")]
    pub ta_cert_sha256: String,
    #[serde(rename = "baseCcrSha256")]
    pub base_ccr_sha256: String,
    #[serde(rename = "deltaCcrSha256", skip_serializing_if = "Option::is_none")]
    pub delta_ccr_sha256: Option<String>,
    #[serde(rename = "hasAspa")]
    pub has_aspa: bool,
    #[serde(rename = "hasRouterKey")]
    pub has_router_key: bool,
    #[serde(rename = "baseVrpCount")]
    pub base_vrp_count: usize,
    #[serde(rename = "baseVapCount")]
    pub base_vap_count: usize,
    #[serde(rename = "deltaVrpCount", skip_serializing_if = "Option::is_none")]
    pub delta_vrp_count: Option<usize>,
    #[serde(rename = "deltaVapCount", skip_serializing_if = "Option::is_none")]
    pub delta_vap_count: Option<usize>,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct BundleManifestV2 {
    #[serde(rename = "schemaVersion")]
    pub schema_version: String,
    #[serde(rename = "bundleProducer")]
    pub bundle_producer: String,
    #[serde(rename = "recordedAt")]
    pub recorded_at_rfc3339_utc: String,
    pub rirs: Vec<String>,
    #[serde(rename = "perRirBundles")]
    pub per_rir_bundles: Vec<BundleManifestEntryV2>,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct BundleManifestEntryV2 {
    pub rir: String,
    pub relative_path: String,
    #[serde(rename = "baseValidationTime")]
    pub base_validation_time: String,
    #[serde(rename = "stepCount")]
    pub step_count: usize,
    #[serde(rename = "firstDeltaValidationTime", skip_serializing_if = "Option::is_none")]
    pub first_delta_validation_time: Option<String>,
    #[serde(rename = "lastDeltaValidationTime", skip_serializing_if = "Option::is_none")]
    pub last_delta_validation_time: Option<String>,
    #[serde(rename = "hasAspa")]
    pub has_aspa: bool,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct BaseBundleStateMetadataV2 {
    #[serde(rename = "validationTime")]
    pub validation_time: String,
    #[serde(rename = "ccrSha256")]
    pub ccr_sha256: String,
    #[serde(rename = "vrpCount")]
    pub vrp_count: usize,
    #[serde(rename = "vapCount")]
    pub vap_count: usize,
    #[serde(rename = "relativeArchivePath")]
    pub relative_archive_path: String,
    #[serde(rename = "relativeLocksPath")]
    pub relative_locks_path: String,
    #[serde(rename = "relativeCcrPath")]
    pub relative_ccr_path: String,
    #[serde(rename = "relativeVrpsPath")]
    pub relative_vrps_path: String,
    #[serde(rename = "relativeVapsPath")]
    pub relative_vaps_path: String,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct DeltaStepMetadataV2 {
    pub index: usize,
    pub id: String,
    #[serde(rename = "relativePath")]
    pub relative_path: String,
    #[serde(rename = "baseRef")]
    pub base_ref: String,
    #[serde(rename = "validationTime")]
    pub validation_time: String,
    #[serde(rename = "deltaCcrSha256")]
    pub delta_ccr_sha256: String,
    #[serde(rename = "vrpCount")]
    pub vrp_count: usize,
    #[serde(rename = "vapCount")]
    pub vap_count: usize,
    #[serde(rename = "relativeArchivePath")]
    pub relative_archive_path: String,
    #[serde(rename = "relativeTransitionLocksPath")]
    pub relative_transition_locks_path: String,
    #[serde(rename = "relativeTargetLocksPath")]
    pub relative_target_locks_path: String,
    #[serde(rename = "relativeCcrPath")]
    pub relative_ccr_path: String,
    #[serde(rename = "relativeVrpsPath")]
    pub relative_vrps_path: String,
    #[serde(rename = "relativeVapsPath")]
    pub relative_vaps_path: String,
    #[serde(rename = "hasAspa")]
    pub has_aspa: bool,
    #[serde(rename = "hasRouterKey")]
    pub has_router_key: bool,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct DeltaSequenceMetadataV2 {
    #[serde(rename = "configuredDeltaCount")]
    pub configured_delta_count: usize,
    #[serde(rename = "configuredIntervalSeconds")]
    pub configured_interval_seconds: u64,
    pub steps: Vec<DeltaStepMetadataV2>,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct RirBundleMetadataV2 {
    #[serde(rename = "schemaVersion")]
    pub schema_version: String,
    #[serde(rename = "bundleProducer")]
    pub bundle_producer: String,
    pub rir: String,
    #[serde(rename = "talSha256")]
    pub tal_sha256: String,
    #[serde(rename = "taCertSha256")]
    pub ta_cert_sha256: String,
    #[serde(rename = "hasAnyAspa")]
    pub has_any_aspa: bool,
    #[serde(rename = "hasAnyRouterKey")]
    pub has_any_router_key: bool,
    pub base: BaseBundleStateMetadataV2,
    #[serde(rename = "deltaSequence")]
    pub delta_sequence: DeltaSequenceMetadataV2,
}
