Skip to main content

alien_core/import/data/azure/
ai.rs

1use serde::{Deserialize, Serialize};
2
3/// Azure AI (AIServices) ImportData.
4///
5/// Carries the account name, endpoint, resource group, and location from an
6/// externally-created AIServices account directly into the controller's ready
7/// state so that heartbeat ticks and binding-param serialization work without
8/// a cloud round-trip.
9#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
10#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
11#[cfg_attr(feature = "jsonschema", derive(schemars::JsonSchema))]
12#[serde(rename_all = "camelCase")]
13pub struct AzureAiImportData {
14    /// Name of the Azure CognitiveServices / AIServices account.
15    pub account_name: String,
16    /// The endpoint URL of the AIServices account.
17    pub endpoint: String,
18    /// Azure resource group containing the account.
19    pub resource_group: String,
20    /// Azure region where the account lives (e.g. "eastus").
21    pub location: String,
22}
23
24#[cfg(test)]
25mod tests {
26    use super::*;
27
28    /// The Azure AI Terraform emitter writes the import ref with camelCase keys
29    /// (`crates/alien-terraform/src/emitters/azure/ai.rs`); it also emits an extra
30    /// `subscriptionId` this struct does not read. This pins the four consumed keys so a
31    /// future rename can't silently break the frozen/Terraform import round-trip.
32    #[test]
33    fn deserializes_the_emitter_import_ref_keys() {
34        let json = serde_json::json!({
35            "subscriptionId": "sub-ignored",
36            "resourceGroup": "my-rg",
37            "accountName": "my-account",
38            "endpoint": "https://my-account.openai.azure.com/",
39            "location": "eastus",
40        });
41        let data: AzureAiImportData =
42            serde_json::from_value(json).expect("the emitter's import-ref keys must deserialize");
43        assert_eq!(data.account_name, "my-account");
44        assert_eq!(data.endpoint, "https://my-account.openai.azure.com/");
45        assert_eq!(data.resource_group, "my-rg");
46        assert_eq!(data.location, "eastus");
47    }
48}