Skip to main content

greentic_types/
provider_install.rs

1//! Provider installation records shared across provisioning workflows.
2
3use alloc::collections::BTreeMap;
4use alloc::string::String;
5
6use semver::Version;
7use serde_json::Value;
8
9#[cfg(feature = "schemars")]
10use schemars::JsonSchema;
11#[cfg(feature = "serde")]
12use serde::{Deserialize, Serialize};
13#[cfg(feature = "time")]
14use time::OffsetDateTime;
15
16use crate::{PackId, ProviderInstallId, TenantCtx};
17
18/// Reference map for configuration or secret entries.
19pub type ProviderInstallRefs = BTreeMap<String, String>;
20
21/// Provider installation record shared across domains.
22#[derive(Clone, Debug, PartialEq)]
23#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
24#[cfg_attr(feature = "schemars", derive(JsonSchema))]
25pub struct ProviderInstallRecord {
26    /// Tenant context for the install.
27    pub tenant: TenantCtx,
28    /// Provider identifier (string-based to avoid enum coupling).
29    pub provider_id: String,
30    /// Installation identifier.
31    pub install_id: ProviderInstallId,
32    /// Pack identifier used for provisioning.
33    pub pack_id: PackId,
34    /// Pack version used for provisioning.
35    #[cfg_attr(
36        feature = "schemars",
37        schemars(with = "String", description = "SemVer version")
38    )]
39    pub pack_version: Version,
40    /// Install creation timestamp.
41    #[cfg(feature = "time")]
42    #[cfg_attr(feature = "serde", serde(with = "time::serde::rfc3339"))]
43    #[cfg_attr(
44        feature = "schemars",
45        schemars(with = "String", description = "RFC3339 timestamp (UTC)")
46    )]
47    pub created_at: OffsetDateTime,
48    /// Install last update timestamp.
49    #[cfg(feature = "time")]
50    #[cfg_attr(feature = "serde", serde(with = "time::serde::rfc3339"))]
51    #[cfg_attr(
52        feature = "schemars",
53        schemars(with = "String", description = "RFC3339 timestamp (UTC)")
54    )]
55    pub updated_at: OffsetDateTime,
56    /// Configuration references produced by provisioning.
57    #[cfg_attr(
58        feature = "serde",
59        serde(default, skip_serializing_if = "BTreeMap::is_empty")
60    )]
61    pub config_refs: ProviderInstallRefs,
62    /// Secret references produced by provisioning.
63    #[cfg_attr(
64        feature = "serde",
65        serde(default, skip_serializing_if = "BTreeMap::is_empty")
66    )]
67    pub secret_refs: ProviderInstallRefs,
68    /// Webhook provisioning state (opaque).
69    #[cfg_attr(feature = "serde", serde(default))]
70    pub webhook_state: Value,
71    /// Subscription provisioning state (opaque).
72    #[cfg_attr(feature = "serde", serde(default))]
73    pub subscriptions_state: Value,
74    /// Free-form metadata from provisioning workflows.
75    #[cfg_attr(feature = "serde", serde(default))]
76    pub metadata: Value,
77}